[PATCH v2] Add reallocarray function.
Florian Weimer
fw@deneb.enyo.de
Mon Apr 17 14:44:00 GMT 2017
* Dennis Wölfing:
> On 17.04.2017 16:32, Florian Weimer wrote:
>> * Dennis Wölfing:
>>
>>> +static inline bool
>>> +check_mul_overflow (size_t l, size_t r, INTERNAL_SIZE_T *result)
>>> +{
>>> +#if __GNUC__ >= 5
>>> + return __builtin_mul_overflow (l, r, result);
>>
>> This is not correct for size_t != INTERNAL_SIZE_T. Either change the
>> type of result to size_t * (so that the code fails to compile if the
>> types differ, something which we have not done for a long time), or
>> add another check against (INTERNAL_SIZE_T) -1.
>
> Are you sure that this is not correct? The GCC manual says about the
> overflow builtins:
Sorry, you are right. I actually tested this, but misread the
generated assembly.
More information about the Libc-alpha
mailing list