[cxx-abi-dev] Run-time array checking
Dennis Handly
dhandly at cup.hp.com
Thu Sep 13 03:32:59 UTC 2012
>From: Mike Herrick <mjh at edg.com>
>On Sep 11, 2012, at 8:44 PM, John McCall wrote:
>> On Sep 11, 2012, at 12:28 PM, Mike Herrick wrote:
>> I hadn't thought of the wider-than-size_t problem, although amusingly I did
>> remember that case when writing the bounds checks in clang.
>>
>> At the risk of prescribing an overly complicated API, I would suggest:
>> void __cxa_throw_bad_array_new_length(uintptr_t sizeData, int flags);
>> where 'flags' is:
>> (sizeof(size) << 1) | std::is_signed<decltype(size)>::value
>> and where sizeData is either:
>> size, converted to a uintptr_t, if sizeof(size) <= sizeof(uintptr_t), or
>> &size otherwise (throwing it in some temporary memory).
>> Converting to a uintptr_t means zero-extending or sign-extending as appropriate.
>Any other opinions on whether we should try to save this value (and if
>so, in which manner)?
Mike.
Wouldn't using a double be good enough?
>> I think that's a reasonable
>> sacrifice for the benefit of letting the ABI library report useful
>> information in the exception.
I have code to print out the size of the bad_alloc request, as useful.
I only print out the first value and don't handle threads perfectly.
sounds good to me.
More information about the cxx-abi-dev
mailing list