<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 26, 2016 at 12:07 AM, Sanjoy Das <span dir="ltr"><<a target="_blank" href="mailto:sanjoy@playingwithpointers.com">sanjoy@playingwithpointers.<wbr>com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">So if you:<br>
<br>
1. override operator delete to do nothing for that type (so that the<br>
placement new actually has unfreed backing storage to re-use).<br>
2. have an empty destructor.<br></blockquote><div>So,<br><br>void *operator new(decltype(sizeof 0), void *) noexcept;<br><br>struct MyInt {<br> static void operator delete(void *) { }<br> MyInt() { x = 0; }<br> ~MyInt() { }<br> int x;<br>};<br><br>float *qq;<br>void foo(void *p, void *q, long unk) {<br> // unk = 1<br> for (long i = 0; i < unk; ++i) {<br> auto pp = new (p) MyInt;<br> delete pp; // or pp->~MyInt();<br> qq = new (static_cast<void *>(&reinterpret_cast<char *>(q)[i])) float(42);<br> }<br>}<br><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span>
</span>then I suspect we'll have the same problem after the destructor and<br>
the operator delete for that type has been inlined away.<br></blockquote><div>Yes; the same problem occurs.<br><br></div><div>So, it sounds like a new intrinsic is in order?<br></div></div></div></div>