Anybody of you got any idea what this "internal compiler error: Segmentation fault" means?

I searched internet, but didn't get anything useful. Then I did my analysis. I found out something peculiar. The code that I am trying to compile is a file for unit testing one of our classes. It contains 880 test cases. All these 880 test cases are individual cases in a switch statement. When I comment out any of the 80 cases (in any order) and keep 800 or less cases in the switch statement, it compiles without giving the above error.

We use CPPUNIT frame work for unit testing.

Here is the complete output.

/<some_path>/MyClassTest.cpp: In static member function `static CppUnit::Test* MyClassTest::suite()':
/<some_path>/MyClassTest.cpp:11774: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccGCtrA5.out file, please attach this to your bugreport.
make[1]: *** [/<some_path>/MyClassTest.o] Error 1
make[1]: Leaving directory `/<some_path>/make'
make: *** [MyClassTest] Error 2

A segmentation fault is normally a memory error, access to an invalid or NULL address. Basically your compiler has crashed compiling your code. This does not necessarily mean there is any error in the code, there could be an bug in the compiler.

Common fixes would be

  1. Use a new version of the compiler with the bug fixed
  2. Restructure your code so it doesn't produce the fault

Use a new version of the compiler with the bug fixed

I suggest this one, because ideally a compiler shouldn't crash no matter what you feed it.

I suggest this one, because ideally a compiler shouldn't crash no matter what you feed it.

Compilers often have bugs just like any other program. I've even had earlier versions of Microsoft compilers crash on me for internal compiler errors.

This happened to me a couple of times before, usually after switching to an experimental version of GCC from the svn development branch. Switching to a stable release or a newer version should fix the problem. This is definitely a problem with the compiler (GCC is usually pretty bug-free, but once in a while, shit happens).

Yes, I will try with the latest compiler. Thanks for all of your suggestions.

If you can post your code that broke the compiler here, it may be illustrative. Usually something weird in the code will cause this sort of problem, although I have broken many compilers with perfectly legal code. In some of those cases I had to rattle cages at the top of the company's engineering heap (VP of engineering for HP, Sun, and DEC come to mind) to get the appropriate attention paid to the problem. Since these problems also jeopardized delivery of software their own companies needed to build their latest manufacturing facilities, usually I was able to get some pretty prompt service... :-)

This article has been dead for over six months. Start a new discussion instead.