fork(1) download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. using std::cout;
  5. using std::endl;
  6.  
  7. struct C;
  8.  
  9. struct B
  10. {
  11. long unsigned int hash;
  12.  
  13. B(C *c);
  14. };
  15.  
  16. struct C : B
  17. {
  18. C() : B(this)
  19. {
  20. cout << "C()" << endl;
  21. }
  22. };
  23.  
  24. B::B(C *c)
  25. {
  26. hash = typeid(*c).hash_code(); //1, UB?
  27. }
  28.  
  29. C c;
  30. int main()
  31. {
  32. cout << c.hash << endl;
  33. cout << typeid(c).hash_code() << endl;
  34. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
C()
3641736028
3641736028