[LLVMbugs] [Bug 7201] New: Undefined references to libstdc++ vtables when compiling with -O2, no problems with -O0

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat May 22 12:14:51 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7201

           Summary: Undefined references to libstdc++ vtables when
                    compiling with -O2, no problems with -O0
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tronic+hfu3 at trn.iki.fi
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


$ cat testi.cc
#include <iostream>
#include <boost/lexical_cast.hpp>

int main() {
    std::cout << boost::lexical_cast<std::string>(1.23) << "Hello\n";
}

$ clang++ testi.cc && ./a.out
1.23Hello
$ clang++ -O2 testi.cc && ./a.out
/tmp/cc.o: In function `bool boost::detail::lexical_stream_limited_src<char,
std::basic_streambuf<char, std::char_traits<char> >, std::char_traits<char>
>::lcast_put<double>(double const&)':
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0x70):
undefined reference to `vtable for std::basic_ostream<char,
std::char_traits<char> >'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0x7b):
undefined reference to `vtable for std::basic_ostream<char,
std::char_traits<char> >'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0x89):
undefined reference to `vtable for std::basic_ostream<char,
std::char_traits<char> >'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0xcf):
undefined reference to `VTT for std::basic_ostream<char, std::char_traits<char>
>'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0xe1):
undefined reference to `VTT for std::basic_ostream<char, std::char_traits<char>
>'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0x140):
undefined reference to `VTT for std::basic_ostream<char, std::char_traits<char>
>'
testi.cc:(.gnu.linkonce.t._ZN5boost6detail26lexical_stream_limited_srcIcSt15basic_streambufIcSt11char_traitsIcEES4_E9lcast_putIdEEbRKT_+0x152):
undefined reference to `VTT for std::basic_ostream<char, std::char_traits<char>
>'
collect2: ld returned 1 exit status
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$

If lexical_cast is removed, the program compiles fine with -O2 too.

20:43 <@baldrick> Tronic: probably the vtable is expected to be output in a
different object file, so the optimizers eliminate it in yours

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list