This is the mail archive of the
mailing list for the GCC project.
Re: Issue with sub-object __builtin_object_size
- From: Jason Merrill <jason at redhat dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: jakub at redhat dot com, gcc at gcc dot gnu dot org
- Date: Tue, 16 Sep 2014 08:27:57 -0400
- Subject: Re: Issue with sub-object __builtin_object_size
- Authentication-results: sourceware.org; auth=none
- References: <201409161023 dot s8GANelH003536 at d06av02 dot portsmouth dot uk dot ibm dot com>
On 09/16/2014 06:23 AM, Ulrich Weigand wrote:
I guess I'm still a bit confused about the special handling of the array
case. Even with the last bit set, array elements normally do not count
as "subobjects", so __builtin_object_size still returns the size of the
I expect that's because there isn't an easy way to distinguish between
the array and the first element.
Now in this case, we cast a pointer to the array to a pointer to a base
type of the array element type -- but the intent is for the pointer to still
refer to the whole array. (Of course, this only works if the base type
is actually the same size as the array type.)
And I'm arguing that this intent is not well expressed by the code. :)
If they want to refer to the whole array, why are they casting the
pointer to a different type? And why are they passing the "subobject
only" value as the second argument?
Note that with a somewhat equivalent C construct:
short int events;
short int revents;
struct pollfd x;
struct Pollfd myfd;
we still get an object size of 80 for either:
__builtin_object_size ((struct pollfd *)myfd, 1);
__builtin_object_size (&myfd->x, 1);
That strikes me as a bug, especially the second one.