<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 5, 2013 at 9:19 PM, Howard Hinnant <span dir="ltr"><<a href="mailto:howard.hinnant@gmail.com" target="_blank" class="cremed">howard.hinnant@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":188" style="overflow:hidden">I must admit to not completely understanding how your path forward is any different from the status-quo.</div>
</blockquote><div><br></div><div>An explicit call to operator new (array or single object) cannot be merged with others according to N3664 (note that the wording has been tweaked in core since that paper, but not in relevant ways). If we implement the standard allocator's allocate function with a raw call to operator new, we don't get the optimizations.</div>
<div><br></div><div>I'm proposing a Clang builtin which allows us to call operator new *without* writing a new-expression, but *with* the optimization freedoms provided by a new-expression.</div><div><br></div><div>This allows us to call the right operator new (ie, not the array version) when doing a raw allocation while permitting the various optimizations.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":188" style="overflow:hidden">  And in that sense, I have absolutely no objection to it.</div>
</blockquote><div><br></div><div>It isn't the status-quo, I'm just explaining it poorly. =] I'll keep trying.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":188" style="overflow:hidden">I do maintain that unless there is a committee change, we need to beware of: </div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":188" style="overflow:hidden">
<div class="im"><br>
#include <vector><br>
<br>
int<br>
main()<br>
{<br>
   std::vector<int> v;<br>
   v.push_back(1);<br>
   return v[0];<br>
}<br>
<br>
</div><div class="im">#include <stdio.h><br>
#include <stdlib.h><br>
<br>
void* operator new[](size_t sz)<br>
{<br>
   printf("I don't like new-array!\n");<br>
   abort();<br>
   return nullptr;<br>
}<br></div></div></blockquote><div><br></div><div>Yes. This means that we cannot implement a raw allocation with "new char[...]" because it calls the wrong overload. My plan is for us to implement raw allocation with "__builtin_allocate(...)" which calls the non-array operator new, but in a way that permits the optimizations.</div>
</div><br></div></div>