On Sat, Jan 14, 2012 at 6:24 PM, Eli Friedman <[email protected]> wrote:
> On Sat, Jan 14, 2012 at 2:47 PM, Aaron Ballman <[email protected]> wrote:
>> While chasing butterflies recently, I noticed the code generated by
>> clang didn't match what was created by MSVC and ICC (but does match
>> what gcc was emitting). Here's a simplified C++ example:
>>
>> void *operator new( unsigned int size ); // note, non-throwing
>
> Per [basic.stc.dynamic.allocation]p3, an operator new which isn't
> marked throw() or noexcept is required to either succeed or throw an
> exception matching std::bad_alloc. clang takes advantage of this by
> skipping the null check.
Good to know, thank you for pointing that out!
> Do you have some specific concern about code which doesn't follow the
> standard?
I just happened to notice the codegen difference for different
reasons, but can imagine a fair amount of code which totally screws up
operator new overloading, such as writing debugging code using malloc,
but failing to specify throw(). Eg)
void *operator new( size_t size ) {
unsigned char *ret = (unsigned char *)::malloc( size + 4 );
*((long *)ret) = kSpecialValue;
return (ret + 4);
}
~Aaron
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits