fail_indirect_member_access.carbon 629 B

1234567891011121314151617
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. package ExplorerTest api;
  7. fn Main() -> i32 {
  8. var pt: {.x: i32, .y: i32};
  9. // TODO: Without this, we don't allow taking the address of `pt.x`.
  10. // That's probably too restrictive.
  11. if (1 == 0) { pt = {.x = 1, .y = 2}; }
  12. var p: i32* = &pt.x;
  13. // CHECK:STDERR: RUNTIME ERROR: fail_indirect_member_access.carbon:[[@LINE+1]]: undefined behavior: access to uninitialized value Uninit<Placeholder<pt>>
  14. return *p;
  15. }