fork download
  1. #include <utility>
  2. #include <memory>
  3. #include <iostream>
  4.  
  5. template<class T>
  6. T& smart_wrap_unwrap(T& v, long)
  7. {
  8. return v;
  9. }
  10.  
  11. template<class T>
  12. auto smart_wrap_unwrap(T& v, int)
  13. -> decltype(smart_wrap_unwrap(v.getPtr(), 0))
  14. {
  15. return smart_wrap_unwrap(v.getPtr(), 0);
  16. }
  17.  
  18. template<class T>
  19. struct smart{
  20. template<class U>
  21. smart(U* v) : _ptr(v){}
  22. T& getPtr(){ return _ptr; }
  23. T _ptr;
  24. };
  25.  
  26. struct X{
  27. void foo(){ std::cout << "!\n"; }
  28. };
  29.  
  30. int main(){
  31. smart<smart<smart<std::shared_ptr<X>>>> smartception(new X());
  32. smart_wrap_unwrap(smartception, 0)->foo();
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
stdout
Standard output is empty