With "g++ -O2" the following code produces (0,0) Segmentation fault on Itanium only. I apologise for leaving the includes in, but these are standard and long includes, so I thought it should be okay. I am unfortunately unable to test with more recent versions. The original project was 10000, and removing nearly any line in this bare-bones version makes the bug go away (the original project isn't that lucky). Compiler information: $ g++ -v -save-temps -O2 Lcommandline.cc Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info -- enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=ia64-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__gnu_linux__ -D__linux -D__linux__ -D_LONGLONG -Dlinux -Dunix -D__gnu_linux__ -D__linux -D__linux__ -D_LONGLONG -D__linux__ -D__unix__ -D__linux -D__unix -Asystem=linux -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=ia64 -Amachine=ia64 -D__ia64 -D__ia64__ -D_LP64 -D__LP64__ -D__ELF__ -D__LONG_MAX__=9223372036854775807L Lcommandline.cc Lcommandline.ii GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (cpplib) (IA-64) Linux ignoring nonexistent directory "/usr/ia64-redhat-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/3.2.3 /usr/include/c++/3.2.3/ia64-redhat-linux /usr/include/c++/3.2.3/backward /usr/local/include /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/include /usr/include End of search list. /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/cc1plus -fpreprocessed Lcommandline.ii -quiet -dumpbase Lcommandline.cc -O2 -version -o Lcommandline.s GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (cpplib) (IA-64) Linux GNU C++ version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (ia64-redhat-linux) compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-42). as -x -o Lcommandline.o Lcommandline.s /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/collect2 -dynamic-linker /lib/ld-linux-ia64.so.2 /usr/lib/ gcc-lib/ia64-redhat-linux/3.2.3/../../../crt1.o /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/../../../crti.o / usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/crtbegin.o -L/usr/lib/gcc-lib/ia64-redhat-linux/3.2.3 -L/ usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/../../.. Lcommandline.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/crtend.o /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/../ ../../crtn.o #include <complex> #include <iostream> using namespace std; struct LL { complex<double> lambda[2]; double gamma[2]; }; complex<double> func(complex<double> s, int what_type, int N, double g, complex<double> l, double Q, int Period, complex<double> delta, char *method) { cerr << s << endl; cerr << what_type << endl; cerr << N << endl; cerr << g << endl; cerr << l << endl; cerr << Q << endl; cerr << Period << endl; cerr << delta << endl; cerr << method << endl; return 0.; } int main () { LL int_L; cout << int_L.lambda[1] << endl; func(complex<double>(0.5,100.), 0, 0, int_L.gamma[1], int_L.lambda[1], 0, 0, 0.,""); return 0; }
Two things. First this is a redhat specific version of GCC: Red Hat Linux 3.2.3. Second 3.2.x is no longer being updated, Can you try 3.4.4?
Subject: Re: Simple code segfaults on itanium I know it is not a good version, and we are trying to get the admin to upgrade it, but until then this is all I have access to. I still wanted to post it to see if it could be tested on higher versions or if it is a known problem. Thank you, Ralph
I am unable to reproduce the problem with FSF gcc-3.2.3 compiled on a debian testing ia64-linux system. Perhaps this is a problem with patches that Red Hat have applied to their gcc sources? I am also unable to reproduce this with gcc-2.96 (debian), gcc-3.3.5 (debian), and FSF gcc mainline (gcc-4.1.0 prerelease). So I have no evidence that any FSF gcc release is broken, and gcc-3.2.x is no longer maintained even if it was broken. I am closing as it works for me.