[LLVMbugs] [Bug 20337] "invalid application of 'sizeof' to an incomplete type" in msvc mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 11 16:38:37 PST 2015


Nico Weber <nicolasweber at gmx.de> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #6 from Nico Weber <nicolasweber at gmx.de> ---
This keeps causing issues (clang-cl's behavior is different from both clang and
cl), so I'd like to look at this some more.

A few observations:

The only thing that generates vtable references in codegen is when emitting a
constructor -- that's the only thing that needs to get the address of the
vtable and write it somewhere. Everything else (virtual calls, etc) just gets
the vtable pointer from the this pointer.

If there's an implicit destructor but an explicit constructor, the complete
destructor seems to go with the explicit constructors (which makes sense since
the constructor needs the vftable, which has a reference to the vector deleting
destructor, which in turn needs to call the real destructor).

This compiles with cl:

template <typename T> class RefPtr {
  T *m_ptr;
  ~RefPtr() { m_ptr->deref(); }

class DeclaredOnly;

struct Base { virtual ~Base(); };

class ReplaceSelectionCommand : public Base {
  RefPtr<DeclaredOnly> m_insertionStyle;
  virtual void trace();
  ReplaceSelectionCommand();  // declared only

void foo() {
  ReplaceSelectionCommand* b = new ReplaceSelectionCommand;
  delete b;

It doesn't build with even regular (non clang-cl) clang because of the delete
call at the end. (it doesn't build with cl if the destructor isn't virtual, of

>From what I can tell ( r182270, r197509, r202046 , r210850 ), the
CheckDestructor call in MarkVTableUsed() in MS mode exists to check that
operator delete is sane, since that's called by the deleting destructor which
is emitted with the vtable. From what I currently understand, we could change
that check to only happen if DefinitionRequired is true (and make sure that
this gets called when constructors are emitted, which is what requires defined
vtables), and to only make it check the operator delete bits.

We probably could also change something in sema to not do complete destructor
checking for `delete b` lines if that calls a virtual destructor.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150112/2b71029f/attachment.html>

More information about the llvm-bugs mailing list