[llvm-bugs] [Bug 26749] New: Incorrect typeinfo symbol visibility when using C++ STL containers

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 26 09:51:24 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26749

            Bug ID: 26749
           Summary: Incorrect typeinfo symbol visibility when using C++
                    STL containers
           Product: new-bugs
           Version: 3.7
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jeffrey.diclemente at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang version used:

clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Mac OS X version: 10.10.5 (Yosemite)


Reproducible test case:

//test_typeinfo_symbols.cpp
#include <typeinfo>
#include <map>
#include <string>

int main(int, char**)
{
    std::map<std::string, int>::const_iterator ci;
    const std::type_info& t = typeid(std::map<std::string, std::string>);
    (void)t;
    return 0;
}

Reproduction steps:

build test_typeinfo_symbols.cpp using:
clang -fvisibility=hidden -isysroot
/Applications/Xcode6.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-stdlib=libc++ -c test_typeinfo_symbols.cpp

run nm against the .o:
nm -om test_typeinfo_symobls.o | c++filt

nm should output the following:
test_typeinfo_symbols.o: 00000000000000c8 (__DATA,__datacoal_nt) weak private
external typeinfo for std::__1::map<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > >,
std::__1::allocator<std::__1::pair<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > > > >
test_typeinfo_symbols.o: 0000000000000050 (__TEXT,__const_coal) weak private
external typeinfo name for std::__1::map<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > >,
std::__1::allocator<std::__1::pair<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > > > >
test_typeinfo_symbols.o:                  (undefined) external vtable for
__cxxabiv1::__class_type_info
test_typeinfo_symbols.o: 0000000000000000 (__TEXT,__text) private external
_main


Now modify test_typeinfo_symbols.cpp to:
//test_typeinfo_symbols.cpp
#include <typeinfo>
#include <map>
#include <string>

int main(int, char**)
{
    const std::type_info& t = typeid(std::map<std::string, std::string>);
    (void)t;
    std::map<std::string, int>::const_iterator ci;
    return 0;
}

build test_typeinfo_symbols.cpp using:
clang -fvisibility=hidden -isysroot
/Applications/Xcode6.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-stdlib=libc++ -c test_typeinfo_symbols.cpp

run nm against the .o:
nm -om test_typeinfo_symobls.o | c++filt

nm should output the following:
test_typeinfo_symbols.o: 00000000000000c8 (__DATA,__datacoal_nt) weak external
typeinfo for std::__1::map<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > >,
std::__1::allocator<std::__1::pair<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > > > >
test_typeinfo_symbols.o: 0000000000000050 (__TEXT,__const_coal) weak external
typeinfo name for std::__1::map<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > >,
std::__1::allocator<std::__1::pair<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > > > >
test_typeinfo_symbols.o:                  (undefined) external vtable for
__cxxabiv1::__class_type_info
test_typeinfo_symbols.o: 0000000000000000 (__TEXT,__text) private external
_main

now the typeinfo is weak external, instead of weak private external.

Why does the order in which the std::map<std::string, int>::const_iterator
appears in the source file change the typeinfo symbol visibility of a different
type? 
This seems like a bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160226/9c894dea/attachment.html>


More information about the llvm-bugs mailing list