[LLVMbugs] [Bug 13424] New: undefined reference to vtable if the virtual destructor is default

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 20 16:46:20 PDT 2012


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

             Bug #: 13424
           Summary: undefined reference to vtable if the virtual
                    destructor is default
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: likan_999.student at sina.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following code can't link for clang++ 3.1, 3.2 and trunk:

[hidden]$ cat x.cpp 
struct X {
    virtual ~X() = default;
    virtual void f();
};

void X::f() {
}

[hidden]$ cat y.cpp 
struct X {
    virtual ~X() = default;
    virtual void f();
};

int main() {
    X x;
}
[hidden]$ clang++ -std=gnu++11 -c x.cpp y.cpp 
[hidden]$ clang++ x.o y.o
y.o:y.cpp:function X::X(): error: undefined reference to 'vtable for X'
clang-3: error: linker command failed with exit code 1 (use -v to see
invocation)


gcc can compile it without any problem.  Obviously clang thinks ~X() as the
first non-inline virtual member so it doesn't generate vtable in x.o.

-- 
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