http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50560
             Bug #: 50560
           Summary: g++ optimization -O3 is removing symbols from
                    templates
    Classification: Unclassified
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: marktrinh.j...@gmail.com


Created attachment 25377
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25377
sample source files to reproduce the problem

gcc 4.5.1:

When compiling/linking my sample library, it seems that the optimization level
-O3 is not finding symbols where -O2 & -O1 works just fine.

make
g++ -g -fPIC -Wall -O3   -c -o bug_Option.o bug_Option.cpp
g++ -g -fPIC -Wall -O3   -c -o UseOption.o UseOption.cpp
g++ -g -shared -Wl,-z,defs -g -shared -o libOption.so bug_Option.o UseOption.o
UseOption.o: In function `foo()':
/tmp/bug/UseOption.cpp:4: undefined reference to
`Option<std::basic_string<char, std::char_traits<char>, std::allocator<char> >
>::Option()'
collect2: ld returned 1 exit status
make: *** [libOption.so] Error 1

I've attached my code.

change the GNUmakefile CXXFLAGS to -O2 to see it work.

Reply via email to