Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang++ emits U symbols while g++ emits none #7195

Closed Quuxplusone closed 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR6738
Status RESOLVED FIXED
Importance P normal
Reported by Roman Divacky (rdivacky@freebsd.org)
Reported on 2010-03-29 12:32:42 -0700
Last modified on 2010-03-30 13:19:28 -0700
Version unspecified
Hardware PC FreeBSD
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, rafael@espindo.la
Fixed by commit(s)
Attachments compatibility.cc (2546 bytes, text/x-c++src)
PR6738.patch (2246 bytes, text/plain)
Blocks
Blocked by
See also
pes delta$ clang++ -c compatibility.cc && nm compatibility.o | grep U
                 U _ZNSt15basic_fstreamXXIcSt11char_traitsIcEED0Ev
                 U _ZNSt15basic_fstreamXXIcSt11char_traitsIcEED1Ev
                 U _ZTVN10__cxxabiv117__class_type_infoE
                 U _ZTVN10__cxxabiv120__si_class_type_infoE
                 U _ZTVN10__cxxabiv121__vmi_class_type_infoE
                 U _ZdlPv
pes delta$ g++ -c compatibility.cc && nm compatibility.o
0000000000000000 W _ZNKSt15basic_fstreamXXIcSt11char_traitsIcEE7is_openEv
                 U __gxx_personality_v0
Quuxplusone commented 14 years ago

Attached compatibility.cc (2546 bytes, text/x-c++src): test case

Quuxplusone commented 14 years ago
Reduced testcase:

class basic_ios {};
template<typename T>
class basic_fstreamXX : virtual public basic_ios {
  void is_open() const  { }
};
template void basic_fstreamXX<char>::is_open() const;

gcc produces only the _ZNK15basic_fstreamXXIcE7is_openEv. Clang gets confused
and produces the VTT and Vtable.

It looks like the bug is in the code that handles the VTT codegen. Replacing
the virtual inheritance with a plain one an adding virtual methods removes the
bug.
Quuxplusone commented 14 years ago
I was wrong, we also produce a vtable for

template<typename T>
class basic_fstreamXX  {
  virtual void foo(){}
  void is_open() const  { }
};
template void basic_fstreamXX<char>::is_open() const;
Quuxplusone commented 14 years ago

Attached PR6738.patch (2246 bytes, text/plain): patch

Quuxplusone commented 14 years ago

fixed in r99900.