This is the code: http://nostdal.net/paste/98e00229c50cdd37fa260737c3625296.html I've tried this with gcc 3.3.3 also: # g++ --version g++ (GCC) 3.3.3 20040217 (Gentoo Linux 3.3.3, propolice-3.3-7) ..with the same results. Also the same results with Dev-C++ (MinGW/GCC 3.2?) under Windows on the machine of a friend of mine. I'll attach the preprocessed source in a moment. Reproducible: Always Steps to Reproduce: 1. I compile the code i link too, like this: g++ a.cpp -o a Actual Results: a.cpp: In function `int main()': a.cpp:43: internal compiler error: Segmentation fault Expected Results: Not crashed. emerge info: Portage 2.0.50-r7 (default-x86-1.4, gcc-3.4.0, glibc-2.3.3_pre20040420-r0, 2.6.5-gentoo-r1) ================================================================= System uname: 2.6.5-gentoo-r1 i686 AMD Athlon(tm) XP 2600+ Gentoo Base System version 1.4.15 distcc 2.14 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] Autoconf: sys-devel/autoconf-2.59-r4 Automake: sys-devel/automake-1.8.5 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-march=athlon-xp -O3 -pipe -ffast-math -ftracer -funroll-loops -funswitch-loops -fpeel-loops -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-march=athlon-xp -O3 -pipe -ffast-math -ftracer -funroll-loops -funswitch-loops -fpeel-loops -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache sandbox" GENTOO_MIRRORS="ftp://ftp.du.se/pub/os/gentoo http://ftp.du.se/pub/os/gentoo http://ds.thn.htu.se/linux/gentoo http://mirror.pudas.net/gentoo ftp://mirror.pudas.net/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage" USE="X alsa apm avi berkdb bonobo cdr crypt cups encode esd foomaticdb gdbm gif gnome gpm gtk gtk2 gtkhtml guile imlib jpeg ldap libg++ libwww mad mikmod motif mozilla mpeg ncurses nls oggvorbis opengl oss pam pdflib perl png python quicktime readline sdl slang spell ssl svga tcltk tcpd tetex truetype x86 xml2 xmms xv zlib"
Created attachment 32432 [details] This is the preprocessed source.
This seems to work: http://nostdal.net/paste/b53b339adb212d0f1a4f6e2ec61e880c.html But still this might be a bug in GCC, since the first code i pasted works in Comeau's online-compiler (it also works in the old VC++6.0-compiler by the way).
I've made the code a bit shorter, here: int defValue() { return(0); } int(*defaultValue)() = defValue; class A { public: A(int value_ = defaultValue()) { } }; int main() { A a; return(0); } Should probably have done this in the first place.
I can reproduce the error, using the code contained at the URL. g++ --version g++ (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
Ok, I've narrowed it down even more: int defValue() { return(0); } int(*defaultValue)() = defValue; void a(int blah = defaultValue()) {} int main() { a(); } And a friend of mine tried: 2.95.3, 3.0.4, 3.1 and 3.2.3. ..all crash. I've decided to file a report to the GCC-maintainers.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15759 I've resolved this bug and set the resolution to "UPSTREAM", hope this is correct; I'm kinda new with this Bugzilla. :)
try adding -fno-unit-at-a-time. if that fixes things, this is a known bug that's being worked on... and a major headache for me :/
$ g++ -fno-unit-at-a-time a.cpp -o a a.cpp: In function `int main()': a.cpp:7: internal compiler error: Segmentation fault Nope, doesn't work. Isn't this option rather new? This bug has existed since 2.95.