undef1.6c 434 B

123456789101112131415161718
  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. // The behavior of this program is undefined because it tries to
  5. // access a local variable after its lifetime is over.
  6. fn f() -> Int* {
  7. var int: x;
  8. x = 0;
  9. return &x;
  10. }
  11. fn main() -> int {
  12. var Ptr(int): p;
  13. p = f();
  14. return *p;
  15. }