fork download
  1. #include <cstdio>
  2.  
  3. struct GameAPI
  4. {
  5. static GameAPI* Ptr;
  6.  
  7. GameAPI()
  8. {
  9. Ptr = this;
  10. }
  11.  
  12. struct
  13. {
  14. void func()
  15. {
  16. printf("%p\n",&Ptr);
  17. }
  18. }test;
  19. };
  20.  
  21. GameAPI* GameAPI::Ptr = nullptr;
  22. void cause_harm()
  23. {
  24. GameAPI kaboom; // goly gee! Did this just set Ptr to a local variable?
  25. } // and did that local variable just go out of scope?
  26.  
  27. int main()
  28. {
  29. cause_harm();
  30. }
Success #stdin #stdout 0s 4440KB
stdin
Standard input is empty
stdout
Standard output is empty