Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal compiler error : segmentation fault with g++4.3.5

Tags:

c++

g++

Here is the code

   //fail_.cpp
   template< unsigned char X, class L>
   class A {
      public:
      typedef void (A::*fptr)();
      class B {   
           public: B(typename A< X, L> ::fptr );
      };
   };
   template < unsigned char X, typename L >
   A<X,L>::B::B ( fptr ) { }

g++ -c fail_.cpp gives

fail_.cpp:11: internal compiler error: Segmentation fault
Please submit a full bug report, with preprocessed source if appropriate.
See < file:///usr/share/doc/gcc-4.3/README.Bugs > for instructions.

Looks like a bug to me in g++4.3.5, g++4.4 and higher don't give any such segfault.

What do you guys think? Is there something wrong with the code itself?

like image 928
Prasoon Saurav Avatar asked Mar 22 '12 08:03

Prasoon Saurav


1 Answers

I see a similar failure with gcc 4.2. As others have said, an internal error means something went badly wrong inside the compiler, which does not imply that it's your code that was bad.

It works fine in g++ 4.6 and clang 3.0.

like image 78
Charphacy Avatar answered Oct 20 '22 05:10

Charphacy