This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Handle flexible arrays in builtin-object-size
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 19 May 2011 05:54:34 -0700
- Subject: Re: [PATCH] Handle flexible arrays in builtin-object-size
- References: <alpine.LNX.2.00.1105191241070.810@zhemvz.fhfr.qr>
On Thu, May 19, 2011 at 3:44 AM, Richard Guenther <rguenther@suse.de> wrote:
>
> This patch makes us deal with flexible array members and global
> initializers correctly, thus for
>
> struct s {
> ? ?int i;
> ? ?char c[];
> } s = { 1, "01234" };
>
> return 6 for the size of s.c instead of 0 (which is wrong, it
> should have been reported as -1 instead - I didn't try to fix
> that particular issue).
>
> For the total size of the pointed-to object we can simply
> use DECL_SIZE_UNIT instead of TYPE_SIZE_UNIT if it is a decl.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk,
> queued for 4.6 (it's a wrong-code bug, but not a regression).
>
> Richard.
>
> 2011-05-19 ?Richard Guenther ?<rguenther@suse.de>
>
> ? ? ? ?PR middle-end/48985
> ? ? ? ?* tree-object-size.c (addr_object_size): If the pointed-to
> ? ? ? ?variable is a decl use DECL_SIZE_UNIT instead of TYPE_SIZE_UNIT.
>
> ? ? ? ?* gcc.dg/builtin-object-size-11.c: New testcase.
>
Testcase failed on Linux/x86:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49063
--
H.J.