Comment 0 for bug 541733

Revision history for this message
Wang Danqi (beyondwdq) wrote : g++ encounters "internal compiler error: Segmentation fault" with precompiled header

Binary package hint: gcc-4.4

Output of lsb_release -rd
 Description: Ubuntu 9.10 Release: 9.10

Output of apt-cache policy g++:
g++:
  Installed: 4:4.4.1-1ubuntu2
  Candidate: 4:4.4.1-1ubuntu2
  Version table:
 *** 4:4.4.1-1ubuntu2 0
        500 http://ftp.science.nus.edu.sg karmic/main Packages
        100 /var/lib/dpkg/status

Problem description:
When I try to compile my c++ code with g++, an "internal compiler error: Segmentation fault" occurs and g++ stops work.
The problem can be reproduced with a simple case with three c++ files, foo.cc foo.h and all.h. The content of these files are as follows:

all.h
#ifndef STDIO_H_
#define STDIO_H_
#include <stdio.h>
#endif /* STDIO_H_ */

foo.h
#include "all.h"

foo.cc
#include "foo.h"

Steps to produce the problem
1) g++ all.h to generate all.h.gch
2) g++ -c foo.cc Then the following error occurs:
c1plus: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.

If I remove all.h.gch and try step 2) again, everything goes fine.

In addition, when I change foo.cc to foo.c and use gcc to repeat step 1) and 2), no error occurs.