[LLVMbugs] [Bug 14557] New: clang doesn't generate "complete object constructor" code when the class contains pure virtual method.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Dec 9 23:08:48 PST 2012


             Bug #: 14557
           Summary: clang doesn't generate "complete object constructor"
                    code when the class contains pure virtual method.
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: orchidnju-dummy at yahoo.com.cn
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

[NOTE] Not sure whether it's clang++ bug, but it's behavior is different from
llvm-g++, so I want to get confirmation on whether clang obey standard and the
behavior is as designed. As a plus, is there any document introduce clang's C++
mangling rule?

[Summary] clang doesn't generate "complete object constructor" (the C1 version)
code when the class contains pure virtual method. 

[Reproduce Steps]
1. create ABISample.cpp to include below code. class A is common class, class B
contains 1 pure virtual method.
class A

class B
    virtual void Foo() = 0;

A::A() {};
B::B() {};

2. compile the code with clang++/g++:
- clang++ -c ABISample.cpp -o clang.o
- g++ -c ABISample.cpp -o g++.o

3. use nm to check generated symbols:
$ nm clang.o 
00000000000000e0 s EH_frame0
0000000000000000 T __ZN1AC1Ev
00000000000000f8 S __ZN1AC1Ev.eh
0000000000000020 T __ZN1AC2Ev
0000000000000120 S __ZN1AC2Ev.eh
0000000000000030 T __ZN1BC2Ev
0000000000000148 S __ZN1BC2Ev.eh
0000000000000068 S __ZTI1B
0000000000000078 S __ZTS1B
0000000000000050 S __ZTV1B
                 U __ZTVN10__cxxabiv117__class_type_infoE
                 U ___cxa_pure_virtual

$ nm g++.o 
00000000000000a8 s EH_frame0
000000000000000a T __ZN1AC1Ev
00000000000000f0 S __ZN1AC1Ev.eh
0000000000000000 T __ZN1AC2Ev
00000000000000c0 S __ZN1AC2Ev.eh
000000000000003c T __ZN1BC1Ev
0000000000000150 S __ZN1BC1Ev.eh
0000000000000014 T __ZN1BC2Ev
0000000000000120 S __ZN1BC2Ev.eh
0000000000000090 S __ZTI1B
00000000000000a0 S __ZTS1B
0000000000000070 S __ZTV1B
                 U __ZTVN10__cxxabiv117__class_type_infoE
                 U ___cxa_pure_virtual

4. compare two symbol list, you can find class B's C1 constructor are generated
by g++ but not clang++:
000000000000003c T __ZN1BC1Ev
0000000000000150 S __ZN1BC1Ev.eh

5. If I remove "= 0" from Foo() to change it from pure virtual to virtual
method, clang will generate C1 constructor.

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