tuple_pointer.carbon 523 B

12345678910111213141516171819202122232425
  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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: 3
  9. // CHECK:STDOUT: 4
  10. // CHECK:STDOUT: result: 0
  11. package ExplorerTest api;
  12. fn Main() -> i32 {
  13. var a: (i32, i32) = (1, 2);
  14. var p: (i32, i32)* = &a;
  15. a[0] = 3;
  16. Print("{0}", (*p)[0]);
  17. (*p)[1] = 4;
  18. Print("{0}", a[1]);
  19. return 0;
  20. }