The command below results in "internal compiler error: Segmentation fault" with the checking- enabled version of GCC 4.0.1 on Suse Linux 9.2. It also crashes with Apple GCC 4.0.0 on Mac OSX 10.4.2. GCC 3.3.4 on Suse rejects the code without crashing, as does CodeSourcery arm-none-linux- gnueabi-g++ 3.4.3, our local version of arm-softfloat-linux-gnu 3.4.1, and (on OSX) Apple's GCC 3.3 and my own build of 3.4.0. /opt/gcc401chk/bin/g++ -c ../cpp/bugfiles/error/EckelRob_104822.ii ../jammed/Barney/eckel.cpp: In function ‘std::string EckelCode::FramisTest()’: ../jammed/Barney/eckel.cpp:2039: internal compiler error: Segmentation fault With the Apple version of GCC 4.0.0, it gives a crash dialog (with a Report… button which doesn't work) with the following text: The application cc1plus quit unexpectedly… EXC_BAD_ACCESS (0x1) KERN_PROTECTION_FAILURE (0X2) at 0xc Thread 0 Crashed: 0 0x1000 + 457016 … I'll attach the preprocessed source. It was copied by Rob Stevenson, a former PalmSource employee, from volume one of Bruce Eckel's _Thinking in C++_. Here's the relevant function: string FramisTest() { stringstream ss2; Framis* f[Framis::psize]; try { for(int i = 0; i < Framis::psize; i++) f[i] = new Framis; new Framis; // Out of memory } catch(bad_alloc) { ss2 << "Out of memory!" << endl; } delete f[10]; f[10] = 0; // Use released memory: Framis* x = new Framis; delete x; for(int j = 0; j < Framis::psize; j++) { ss2 << f[j]->ReturnStrStream() ; delete f[j]; // Delete f[10] OK } return ss2.str() ; } ///:~ ______________________________________ Configurations: Suse: 62> /opt/gcc401chk/bin/g++ -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --enable-checking --prefix=/opt/gcc401chk --enable-languages=c,c+ + Thread model: posix gcc version 4.0.1 63> uname -a Linux thrallis 2.6.8-24.16-default #1 Thu Jun 2 12:09:57 UTC 2005 i686 i686 i386 GNU/Linux Macintosh: > gcc -v Reading specs from /usr/lib/gcc/powerpc-apple-darwin8/4.0.0/specs Configured with: /private/var/tmp/gcc/gcc-4061.obj~8/src/configure --disable-checking --prefix=/ usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^ [cg][^+.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ --build=powerpc- apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061) 112> uname -a Darwin klono.local 8.2.0 Darwin Kernel Version 8.2.0: Fri Jun 24 17:46:54 PDT 2005; root:xnu-792.2.4.obj~3/RELEASE_PPC Power Macintosh powerpc PalmSource bug #104822 --- Flash Sheridan http://pobox.com/~flash Quality Lead for Compilers and Debuggers PalmSource, Inc. Tools Quality Management
Created attachment 9287 [details] Preprocessed source file
Confirmed, reduced testcase: typedef __SIZE_TYPE__ size_t; struct Framis { void* operator new(size_t) throw(bad_alloc); }; Framis* x = new Framis;
Testing a patch.
Subject: Bug 22508 CVSROOT: /cvs/gcc Module name: gcc Changes by: reichelt@gcc.gnu.org 2005-08-08 17:03:33 Modified files: gcc/cp : ChangeLog init.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: new13.C Log message: PR c++/22508 * init.c (build_new_1): Check for empty candidate list. * g++.dg/init/new13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4844&r2=1.4845 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.425&r2=1.426 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5893&r2=1.5894 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 22508 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: reichelt@gcc.gnu.org 2005-08-08 17:06:39 Modified files: gcc/cp : ChangeLog init.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: new13.C Log message: PR c++/22508 * init.c (build_new_1): Check for empty candidate list. * g++.dg/init/new13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.72&r2=1.4648.2.73 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.412.2.5&r2=1.412.2.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.322&r2=1.5084.2.323 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new13.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed on mainline and 4.0 branch.
Subject: Bug 22508 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: reichelt@gcc.gnu.org 2005-10-20 10:10:10 Modified files: gcc/cp : ChangeLog init.c Log message: PR c++/22508 * init.c (build_new_1): Remove misleading comment. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.247&r2=1.3892.2.248 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.356.2.18&r2=1.356.2.19