[LLVMbugs] [Bug 13684] New: Explicitly deleted virtual member function causes link error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 23 17:31:15 PDT 2012


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

             Bug #: 13684
           Summary: Explicitly deleted virtual member function causes link
                    error
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: arthur.j.odwyer at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


cat >test.cc <<EOF
struct Base {
    virtual void bar();
    virtual void foo() = delete;
};

void Base::bar() { }  // a definition of the first non-inline virtual function
int main() { Base b; }
EOF
clang++ -std=c++11 test.cc

Undefined symbols for architecture x86_64:
  "Base::foo()", referenced from:
      vtable for Base in test-6qnzYL.o

N3337 Section 8.4.3#1 seems fairly clear that a deleted-definition does in fact
count as an (inline) function-definition, which means a deleted definition
satisfies 10.3#11:

> A virtual function declared in a class shall be defined, or declared
> pure in that class, or both; but no diagnostic is required.

However, it seems that Clang disagrees. Clang won't link the following program,
complaining that the definition of `foo` is missing. And if you swap the order
of `foo` and `bar`, Clang complains that the entire vtable is missing
(presumably because Clang thinks `foo` is a non-inline function with no
definition).

cat >test.cc <<EOF
struct Base {
    virtual void foo() = delete;
    virtual void bar();
};

void Base::bar() { }  // still a definition of the first non-inline virtual
function
int main() { Base b; }
EOF
clang++ -std=c++11 test.cc

Undefined symbols for architecture x86_64:
  "vtable for Base", referenced from:
      Base::Base() in test-FytcYY.o
  NOTE: a missing vtable usually means the first non-inline virtual member
function has no definition.

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