fork download
  1. #include <iostream>
  2.  
  3. struct A {};
  4.  
  5. A a, b, c;
  6.  
  7. A* ptr = &a;
  8.  
  9. void report(A* p) {
  10. std::cout << (void*) &a << ", " << (void*) &b << ", " << (void*) &c
  11. << ": " << (void*) p << "\n";
  12. }
  13.  
  14. int f() {
  15. std::cout << "f() ";
  16. report(ptr);
  17. }
  18.  
  19. int main() {
  20. report(ptr);
  21. if (ptr != nullptr) {
  22. A* ptr = &b;
  23. report(ptr);
  24. if (ptr != nullptr) {
  25. A* ptr = &c;
  26. report(ptr);
  27. }
  28. report(ptr);
  29. }
  30. report(ptr);
  31. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0x8049c2f, 0x8049c2e, 0x8049c2d: 0x8049c2f
0x8049c2f, 0x8049c2e, 0x8049c2d: 0x8049c2e
0x8049c2f, 0x8049c2e, 0x8049c2d: 0x8049c2d
0x8049c2f, 0x8049c2e, 0x8049c2d: 0x8049c2e
0x8049c2f, 0x8049c2e, 0x8049c2d: 0x8049c2f