Problem with Object Size Checking and reallocarray

Yaakov Selkowitz yselkowitz@cygwin.com
Tue Mar 13 14:06:00 GMT 2018


On 2018-03-13 07:51, Corinna Vinschen wrote:
> On Mar 12 19:58, Jon Turney wrote:
>> reallocarray() is annotated in stdlib.h with '__alloc_size(2)
>> __alloc_size(3)'
>>
>> per [1], this doesn't seem to be the correct syntax when the size is the
>> product of the arguments, and the last alloc_size seems to be silently
>> winning.
>>
>> If I change this to '__alloc_size((2,3))' (as in the patch attached),
>> __builtin_object_size doesn't seem to be a compile-time constant anymore,
>> and so memcpy() evaluates differently, so it's hard to be sure that's
>> actually correct...
>>
>> [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
> 
> Yaakov, care to comment and push if the patch is ok?

Thanks, pushed.

-- 
Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20180313/94805b85/attachment.sig>


More information about the Newlib mailing list