public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107952] tree-object-size: inconsistent size for flexible arrays nested in structs
Date: Tue, 24 Jan 2023 10:04:15 +0000 [thread overview]
Message-ID: <bug-107952-4-Q1JcTq7Uva@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107952-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107952
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to qinzhao from comment #7)
> (In reply to Richard Biener from comment #1)
> > GCC considered this as a flex-array.
>
> do you mean for the following example:
>
> typedef struct {
> char pad;
> char data[];
> } F2;
>
> typedef struct {
> unsigned pad;
> F2 flex;
> } S2;
>
> although C standard disallow the above, GCC extension treats S2.flex.data as
> a flex-array?
>
> How about:
>
> typedef struct {
> char pad;
> char data[];
> } F2;
>
> typedef struct {
> F2 flex;
> unsigned pad;
> } S2;
>
> do we have any documentation on this Gcc extension?
GCC handles for example
struct A { char data[1]; };
struct B { int n; struct A a; };
as if the a.data[] array is a flex-array. It also handles
struct C { int n; struct A a; int x; };
as if a.data[] can be up to 4 elements large (we allow an array to extend
flexibly to padding - but only if it is trailing). I see that's not
consistently handled though.
I think the [] syntax should follow the C standard as what testcases are
accepted/rejected by the frontend and any extensions there should be
documented (those are separate from what the former array_at_struct_end_p
allowed semantically and where GCC is careful with optimization because
of code out in the wild).
next prev parent reply other threads:[~2023-01-24 10:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 14:04 [Bug tree-optimization/107952] New: " siddhesh at gcc dot gnu.org
2022-12-05 8:05 ` [Bug tree-optimization/107952] " rguenth at gcc dot gnu.org
2022-12-05 12:46 ` siddhesh at gcc dot gnu.org
2022-12-05 13:15 ` jakub at gcc dot gnu.org
2022-12-05 15:11 ` rguenther at suse dot de
2022-12-05 15:28 ` siddhesh at gcc dot gnu.org
2023-01-23 19:39 ` qinzhao at gcc dot gnu.org
2023-01-23 19:44 ` qinzhao at gcc dot gnu.org
2023-01-23 21:30 ` siddhesh at gcc dot gnu.org
2023-01-24 10:04 ` rguenth at gcc dot gnu.org [this message]
2023-01-24 15:24 ` qing.zhao at oracle dot com
2023-01-25 7:32 ` rguenther at suse dot de
2023-01-25 12:44 ` siddhesh at gcc dot gnu.org
2023-01-25 15:14 ` qing.zhao at oracle dot com
2023-01-25 16:12 ` siddhesh at gcc dot gnu.org
2023-01-25 16:40 ` qing.zhao at oracle dot com
2023-01-25 21:16 ` siddhesh at gcc dot gnu.org
2023-01-25 21:43 ` qinzhao at gcc dot gnu.org
2023-01-26 7:20 ` rguenth at gcc dot gnu.org
2023-01-26 22:13 ` qinzhao at gcc dot gnu.org
2023-01-27 7:46 ` rguenther at suse dot de
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-107952-4-Q1JcTq7Uva@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).