<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 1, 2009, at 7:50 PM, Anders Carlsson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div><blockquote type="cite"><blockquote type="cite"><font class="Apple-style-span"><br></font></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">What if there isn't any valid delete operator?  I'm not entirely sure<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">off the top of my head how that would happen, but I think it's<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">possible.  We don't print a diagnostic, and there isn't a delete<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">operator, so we're back to crashing.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I thought about this too. I think this will not happen. If we have a<br></blockquote><blockquote type="cite">declaration which eventually requires<br></blockquote><blockquote type="cite">the delete operator for its destruction, the CheckDestructor is called and<br></blockquote><blockquote type="cite"> operator delete will<br></blockquote><blockquote type="cite">be looked up. Except that this time a diagnostic will be issued.<br></blockquote><br>If it's in the vtable, the destructor might be called, even if the<br>call isn't obvious.  That isn't really the issue here anyway, though:<br>the issue is that it would crash trying to generate the destructor,<br>whether or not it's actually called.<br><br></div></blockquote><div><br></div>Incidentally, I'm working on a fix for this :) Basically, when we emit a function definition, we check if it's the key function (where the vtable should be emitted). </div><div><br></div><div>If it is the key function, indicating that this is where the vtable will be emitted by codegen, then we mark all the implicit virtual declarations (the dtor, and maybe the assignment operator?) as referenced. </div><div><br></div><div>If the record decl does not have a key method, we mark the virtual declarations when we encounter the constructor instead, because that's where the vtable will be first used.</div></div></blockquote><div><br></div>Great. This is the right way to go.</div><div><br></div><div>- Fariborz</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Anders</div><div><br></div></div></blockquote></div><br></body></html>