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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Dec 10 08:12:11 PST 2012


> 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



More information about the cfe-dev mailing list