<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:nicolasweber@gmx.de" title="Nico Weber <nicolasweber@gmx.de>"> <span class="fn">Nico Weber</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - "invalid application of 'sizeof' to an incomplete type" in msvc mode"
   href="http://llvm.org/bugs/show_bug.cgi?id=20337">bug 20337</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>WONTFIX
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - "invalid application of 'sizeof' to an incomplete type" in msvc mode"
   href="http://llvm.org/bugs/show_bug.cgi?id=20337#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - "invalid application of 'sizeof' to an incomplete type" in msvc mode"
   href="http://llvm.org/bugs/show_bug.cgi?id=20337">bug 20337</a>
              from <span class="vcard"><a class="email" href="mailto:nicolasweber@gmx.de" title="Nico Weber <nicolasweber@gmx.de>"> <span class="fn">Nico Weber</span></a>
</span></b>
        <pre>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;
public:
  ~RefPtr() { m_ptr->deref(); }
};

class DeclaredOnly;

struct Base { virtual ~Base(); };

class ReplaceSelectionCommand : public Base {
  RefPtr<DeclaredOnly> m_insertionStyle;
public:
  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
course.)

>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>