<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 12, 2012, at 16:50 , Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Wed, Sep 12, 2012 at 4:32 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">>> The second way is if -fcatch-undefined-behavior could be augmented to handle this case. I have no idea how to do this, though -- perhaps it requires something ASan-ish to poison the temporary memory once its lifetime ends.</div>
<div class="HOEnZb"><div class="h5">
>><br>
>> Any chance of either of these happening on trunk?<br></div></div></blockquote><div> </div><div>We'd want to wait until the end of the storage duration rather than the end of the lifetime of the object, but yes, we could do that (for instance, we could emit llvm lifetime intrinsics for all local variables, and teach ASan to poison memory based on them).</div>
</div>
</blockquote><br></div><div>Well, I'm not entirely sure what you mean by this, but AFAICT the issue is that GCC thinks the storage duration ends sooner than we think it does. In this test case (with a recent Xcode clang), we're definitely calling the destructor before we print the field.</div><div><br></div><div><div>#include <iostream></div><div><br></div><div>struct A {</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>int x;</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>const A *get() const { return this; } </div><div><span class="Apple-tab-span" style="white-space:pre">  </span>~A() { std::cout << "bye\n"; }</div><div>};</div><div><br></div><div>int main() {</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>const A *a = A().get();</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>std::cout << a->x << "\n";</div><div>}</div><div><br></div></div><br></body!
 ></html>