On Wed, May 29, 2013 at 1:01 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wed, May 29, 2013 at 3:55 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> On Wed, May 29, 2013 at 7:49 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> #include <stdio.h><br>
>> #include <stdlib.h><br>
>><br>
>> struct arbitrary_t {} arbitrary;<br>
>><br>
>> void *operator new[]( size_t s, arbitrary_t ) throw() { return ::malloc( s<br>
>> ); }<br>
>><br>
>> struct S {<br>
>>   void *operator new( size_t s, arbitrary_t ) throw() { return ::malloc( s<br>
>> ); }<br>
>> };<br>
>><br>
>> int main() {<br>
>>   S *s = new (arbitrary) S[2];<br>
>> }<br>
>><br>
>> This will yield a call to the global operator new[] instead of the<br>
>> class-specific operator new.  Using new instead of new[] yields a call<br>
>> to the matching class-specific operator new still.  So I think my test<br>
>> will have to move down below the check for a global operator new:<br>
>><br>
>>  <look for member operator new><br>
>>  <look for global operator new><br>
>> +if (not found && looking for array new && MS mode)<br>
>> +  <switch to looking for non-array new><br>
>> +  <look for global operator new><br>
>><br>
>> If you agree, then I'll make the changes and add another test to<br>
>> CodeGenCXX to ensure we're calling the proper one.<br>
><br>
><br>
> What happens if you remove the global array new? Is the class-specific<br>
> non-array new used then?<br>
<br>
</div></div>You get an error:<br>
<br>
F:\Aaron Ballman\Desktop\test6.cpp(13) : error C2660: 'operator new' : function<br>
does not take 2 arguments</blockquote><div><br></div><div>Weird... well, OK then.</div><div><br></div><div>The indentation in SemaExprCXX.cpp in your latest patch looks a bit off (maybe you ran diff with -b or -w?), otherwise LGTM.</div>
</div>