8691 – [3.2 regression] -O3 and -fno-implicit-templates are incompatible (original) (raw)
| The following program fails to build with `-O3 -fno-implicit-templates': lidiaadm@lap200:~/gcc-3.2/bugs> cat string-O3.cc #include int main() { std::string ("Hello World!"); return 0; } lidiaadm@lap200:~/gcc-3.2/bugs> g++ -Wall -O3 -fno-implicit-templates -o string-O3 string-O3.cc /tmp/ccQrTsAF.o: In function `main': /tmp/ccQrTsAF.o(.text+0x40): undefined reference to `char* std::basic_string<char, std::char_traits, std::allocator >::_S_construct<char const*>(char const*, char const*, std::allocator const&, std::forward_iterator_tag)' collect2: ld returned 1 exit status Experimenting with `-fkeep-inline-functions' etc. didn't help. If string-O3.cc is compiled with `-O2 -fno-implicit-templates' or simply `-O3', everything is ok. It seems the optimizer interacts in some strange way with template instantiation. Since we observed the problem with std::string, one may put this PR in the category libstdc++. But in my opinion the user can't be supposed to anticipate what the optimizer is going to do; therefore the set of required explicit template instantiations should not be depend on the optimization level and I think it's a bug in the C++ front end. If you don't consider gcc's behaviour a bug, then I request that the documentation explicitly states that one can't use `-fno-implicit-templates' with `-O3' or higher. Release: gcc version 3.2 Environment: linux 2.4.18 i686 How-To-Repeat: g++ -Wall -O3 -fno-implicit-templates -o string-O3 string-O3.cc Comment 1 cludwig 2002-11-24 06:06:00 UTC Fix: Workaround: Restrict optimization to `-O2'. Comment 2 Volker Reichelt 2002-11-24 13:30:49 UTC State-Changed-From-To: open->feedback State-Changed-Why: I cannot reproduce the bug with 3.2 (or 3.1 or 3.2.1) on i686-pc-linux-gnu (using the original testcase and the preprocessed version). Are you really using the gcc 3.2 release or some prerelease or some modified version from a LINUX distributor instead? If the latter is true, you should try to install gcc 3.2.1 from source. Please contact us, whether the problems still persist or vanished. In the latter case, please add "-v" to the command line options and provide us with the output so that we we can investigate the problem. Comment 3 Volker Reichelt 2002-11-24 16:53:43 UTC State-Changed-From-To: feedback->analyzed State-Changed-Why: Confirmed. May be a binutils issue. Comment 4 pcarlini 2002-11-25 00:50:50 UTC From: Paolo Carlini <pcarlini@unitus.it> To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, cludwig@cdc.informatik.tu-darmstadt.de, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, Reichelt <reichelt@igpm.rwth-aachen.de> Cc: Subject: Re: c++/8691: -O3 and -fno-implicit-templates are incompatible Date: Mon, 25 Nov 2002 00:50:50 +0100 Hi, I can reproduce the problem. Ciao, Paolo. //////// paolo:~> g++ -v -O3 -fno-implicit-templates 8691.cc Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs Configured with: ../gcc-3.2.1/configure --prefix=/usr Thread model: posix gcc version 3.2.1 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ 8691.cc -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase 8691.cc -O3 -version -fno-implicit-templates -o /tmp/cc1au9LA.s GNU CPP version 3.2.1 (cpplib) (i386 Linux/ELF) GNU C++ version 3.2.1 (i686-pc-linux-gnu) compiled by GNU C version 3.2.1. #include "..." search starts here: #include <...> search starts here: /usr/include/c++/3.2.1 /usr/include/c++/3.2.1/i686-pc-linux-gnu /usr/include/c++/3.2.1/backward /usr/local/include /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/include /usr/i686-pc-linux-gnu/include /usr/include End of search list. /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/cc457xQo.o /tmp/cc1au9LA.s GNU assembler version 2.13.1 (i686-pc-linux-gnu) using BFD version 2.13.1 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crt1.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crti.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/crtbegin.o -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1 -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../.. /tmp/cc457xQo.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/crtend.o /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crtn.o /tmp/cc457xQo.o: In function `main': /tmp/cc457xQo.o(.text+0x40): undefined reference to `char* std::basic_string<char, std::char_traits, std::allocator >::_S_construct<char const*>(char const*, char const*, std::allocator const&, std::forward_iterator_tag)' collect2: ld returned 1 exit status http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8691 Comment 7 cludwig 2002-11-25 09:20:59 UTC From: Christoph Ludwig <cludwig@cdc.informatik.tu-darmstadt.de> To: reichelt@igpm.rwth-aachen.de, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/8691: -O3 and -fno-implicit-templates are incompatible Date: Mon, 25 Nov 2002 09:20:59 +0100 Others already confirmed they can reproduce the bug with specific binutils versions. Just for completeness, here is the data you asked for: lidiaadm@lap200:~> g++ -v Reading specs from /opt/gcc/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: /home/lidiaadm/tmp/gcc-3.2-src/gcc-3.2/configure --prefix=/opt/gcc/gcc-3.2 --enable-threads=posix --enable-version-specific-runtime-libs --enable-__cxa_atexit Thread model: posix gcc version 3.2 I am running SuSE Linux with the binutils that shipped with the distribution: lidiaadm@lap200:~> ld -v GNU ld version 2.11.92.0.10 20011021 (SuSE) Just in case it helps you tracking down the problem's cause: On my system, gcc 3.1 is the first compiler release that fails to build the test program. 3.0.4 builds it fine. Regards Christoph On Sun, Nov 24, 2002 at 09:30:50PM -0000, reichelt@igpm.rwth-aachen.de wrote: > Synopsis: -O3 and -fno-implicit-templates are incompatible > > State-Changed-From-To: open->feedback > State-Changed-By: reichelt > State-Changed-When: Sun Nov 24 13:30:49 2002 > State-Changed-Why: > I cannot reproduce the bug with 3.2 (or 3.1 or 3.2.1) > on i686-pc-linux-gnu (using the original testcase and the > preprocessed version). > Are you really using the gcc 3.2 release or some prerelease > or some modified version from a LINUX distributor instead? > If the latter is true, you should try to install gcc 3.2.1 > from source. > Please contact us, whether the problems still persist > or vanished. In the latter case, please add "-v" to the > command line options and provide us with the output so that we > we can investigate the problem. > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8691 -- http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html LiDIA-CA: http://www.informatik.tu-darmstadt.de/TI/Forschung/LiDIA-CA/ Comment 8 Joe Buck 2003-04-25 21:24:47 UTC State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for 3.3. | | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |