fork download
  1. #include <typeinfo>
  2.  
  3. class C {};
  4.  
  5. template<typename T>
  6. void* startOfObject(T* p) {
  7. void* q = static_cast<void*>(p);
  8. typeid(q = dynamic_cast<void*>(p), *p); // this line
  9. return q;
  10. }
  11.  
  12. int main() {
  13. C c;
  14.  
  15. startOfObject(&c);
  16. return 0;
  17. }
  18.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void* startOfObject(T*) [with T = C]’:
prog.cpp:15:21:   required from here
prog.cpp:8:12: error: cannot dynamic_cast ‘p’ (of type ‘class C*’) to type ‘void*’ (source type is not polymorphic)
   typeid(q = dynamic_cast<void*>(p), *p); // this line
            ^
stdout
Standard output is empty