fork download
  1. #include <iostream>
  2.  
  3. struct foo_t
  4. {
  5. int& a;
  6. };
  7.  
  8. struct bar_t
  9. {
  10. int* a;
  11. };
  12.  
  13. int main()
  14. {
  15. bar_t bar{ 0 };
  16. foo_t foo( *reinterpret_cast< foo_t* >( &bar ) );
  17.  
  18. int& nullref = foo.a;
  19.  
  20. std::cout << "&nulref: "<< &nullref << std::endl;
  21. }
  22.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
&nulref: 0