fail_store_to_uninitialized_class.carbon 576 B

1234567891011121314151617181920212223
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. class Point {
  8. var x: i32;
  9. var y: i32;
  10. }
  11. fn Main() -> i32 {
  12. var p: Point;
  13. if (1 == 0) {
  14. p = {.x = 0, .y = 0};
  15. }
  16. // CHECK:STDERR: RUNTIME ERROR: fail_store_to_uninitialized_class.carbon:[[@LINE+1]]: undefined behavior: store to subobject of uninitialized value Uninit<Placeholder<p>>
  17. p.x = 1;
  18. p.y = 2;
  19. return p.x;
  20. }