http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53439
Bug #: 53439 Summary: g++ generates buggy code with optimisation flags Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: christophe.prudho...@feelpp.org Dear Maintainer, * What led up to the situation? I ported feel++ (http://www.feelpp.org) to gcc47 and found out that it generates buggy code(generating segfault) in optimisation mode. Here are the steps to reproduce it - install feel++-apps (Debian package, apt-get install feel++-apps) - execute feel_doc_myfunctionspace (compiled using CMAKE_BUILD_TYPE=Release) - it generates a segfault what happens is that a data structure containing only a double data member seem to be optimized away and became dangling reference (invalid read using valgrind). The code crashes at line 220 of doc/manual/tutorial/myfunctionspace.cpp when evaluating the expression template data structure g defined on line 215. - in RelWithDebInfo(-g -O1) and Release (-O3) gcc47 generates segfault - in gcc47 with CMAKE_BUILD_TYPE=Debug, it works without problems - with gcc45, gcc46, clang31 on Linux and OSX there are no problems at all in RelWithDebInfo and Release mode (CMAKE_BUILD_TYPE) Hence I believe that this is a bug in gcc47 code generation/optimisation. The failures occurs with g++4.7 on macports and Debian unstable * compiler: g++-4.7 (Debian 4.7.0-8) and Macport g++-mp-4.7 4.7.0_3 * system: Debian unstable and MacOsX Lion 10.7.3 (macports 2.1) * cmdline /usr/bin/c++ -DBOOST_UBLAS_MOVE_SEMANTICS -DFEELPP_HAS_MPI=1 -DFEELPP_HAS_MPI_H=1 -DFEELPP_HAS_DLFCN_H -DFEELPP_HAS_DLOPEN -DBOOST_PARAMETER_MAX_ARITY=20 -DBOOST_TEST_DYN_LINK -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_NO_SCOPED_ENUMS -DFEELPP_HAS_PETSC -DFEELPP_HAS_PETSC_H -DFEELPP_HAS_GMSH=1 -D_FEELPP_HAS_GMSH_ -DGMSH_EXECUTABLE=/usr/bin/gmsh -std=c++0x -pedantic -ftemplate-depth-256 -Wno-inline -std=c++0x -g -O1 -I/home/prudhomm/Devel/FEEL/feelpp.git/contrib -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi -I/usr/include/libxml2 -I/home/prudhomm/Devel/FEEL/feelpp.git/contrib/eigen -I/home/prudhomm/Devel/FEEL/feelpp.git/contrib/gmm -I/usr/include/ANN -I/usr/include/python2.7 -I/usr/lib/petscdir/3.2/include -I/usr/lib/petscdir/3.2/linux-gnu-c-opt/include -I/usr/lib/slepcdir/3.2/linux-gnu-c-opt/include -I/usr/lib/slepcdir/3.2/include -I/usr/include/vtk-5.8 -I/usr/include/gmsh -I/home/prudhomm/Devel/FEEL/relwithdebingo.gcc47 -I/home/prudhomm/Devel/FEEL/feelpp.git -I/home/prudhomm/Devel/FEEL/feelpp.git/contrib/gmm/include -I/home/prudhomm/Devel/FEEL/feelpp.git/doc/manual -Wall -Wno-unused -Wno-sign-compare -o CMakeFiles/feel_doc_laplacian.dir/laplacian.cpp.o -c /home/prudhomm/Devel/FEEL/feelpp.git/doc/manual/tutorial/laplacian.cpp the .i files archive is just too big, you can find it here [1] 1. http://feelpp.googlecode.com/files/feel-gcc-ifiles.tar.gz