fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct bar {
  6. struct foo {
  7. foo () {
  8. cerr << "foo" << endl;
  9. }
  10. int i = 42;
  11. };
  12.  
  13. static thread_local foo FOO;
  14. };
  15.  
  16. static thread_local bar::foo FREE_FOO;
  17. thread_local bar::foo bar::FOO;
  18.  
  19. int main() {
  20. bar b;
  21. cerr << "main" << endl;
  22. cerr << FREE_FOO.i << endl;
  23. cerr << b.FOO.i << endl;
  24. return 0;
  25. }
Success #stdin #stdout #stderr 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
main
foo
foo
42
42