Is it a bug? clang doesn't generate "complete object constructor" code when the class contains pure virtual method.

I’m migrating a project from GCC to Clang on OS X, and meet 1 code generation difference by clang/gcc: clang doesn’t generate “complete object constructor” (the C1 version) code when the class contains pure virtual method, but gcc does, (and llvm-gcc also does).

I’m not sure whether this is a clang bug, but could anyone tell me whether clang acts properly? Is there any standard that defines whether compiler shouldn’t generate C1 version construct when the class has pure virtual method?

Below is the detail information related with the issue I met:

[Summary] clang doesn’t generate “complete object constructor” (the C1 version)

code when the class contains pure virtual method. 


[Clang Version] Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)

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

I'm not sure whether this is a clang bug, but could anyone tell me whether
clang acts properly? Is there any standard that defines whether compiler
shouldn't generate C1 version construct when the class has pure virtual
method?

I looked at http://mentorembedded.github.com/cxx-abi/abi.html, but
could not find anything.

===============================
class A
{
public:
    A();
};

class B
{
public:
    B();
    virtual void Foo() = 0;
};

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

...

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

Do you see a case where we get a undefined reference to __ZN1BC1Ev?
Since the class has a pure virtual method, I would expect that it is
only constructed as part of building a larger object, and so this is a
valid clang optimization, no?

Cheers,
Rafael

This was also reported as PR14557 (in future, please don't fragment
the discussion like that!). This seems like a valid optimization to
me.