[cxx-abi-dev] Run-time array checking

Dennis Handly dhandly at cup.hp.com
Tue Sep 11 21:37:54 UTC 2012


>From: Mike Herrick <mjh at edg.com>
>On Sep 10, 2012, at 12:35 PM, John McCall wrote:
>> 1) Adding the new __cxa_throw_bad_array_new_length routine.  There's a
>>still an open question here, I think:  it's a better user experience if
>>std::bad_array_new_length carries the length argument.  Unfortunately
>>(a) that's a bit complicated to encode as an operand to the routine,
>>because we'd also need to track whether that's signed or unsigned, and

>We agree that having the length argument is desirable from a user's
>point of view, but it seems rather difficult for the compiler to convey
>this value to a library routine given that its type may be signed or
>unsigned and it may or may not be larger than size_t/ptrdiff_t.

There's a simple solution to this.  Use evil floating point, a double.
While it isn't precise for allocation, it will be properly signed and at
least handle large magnitude values for any error message.


More information about the cxx-abi-dev mailing list