http://llvm.org/bugs/show_bug.cgi?id=20337
Nico Weber <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WONTFIX |--- --- Comment #6 from Nico Weber <[email protected]> --- 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. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
