From: Qing Zhao <qing.zhao@oracle.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Joseph Myers <joseph@codesourcery.com>,
"sandra@codesourcery.com" <sandra@codesourcery.com>,
Siddhesh Poyarekar <siddhesh@gotplt.org>,
Kees Cook <keescook@chromium.org>,
Richard Biener <richard.guenther@gmail.com>,
gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [V5][PATCH 2/2] Update documentation to clarify a GCC extension
Date: Mon, 27 Mar 2023 16:22:25 +0000 [thread overview]
Message-ID: <E460392E-194F-47D9-9796-56F1E1E3D7F9@oracle.com> (raw)
In-Reply-To: <ZCG++DFli6xBlucX@tucnak>
> On Mar 27, 2023, at 12:06 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Mar 27, 2023 at 03:57:58PM +0000, Qing Zhao wrote:
>>>> +Please use warning option @option{-Wgnu-variable-sized-type-not-at-end} to
>>> This is certainly misnamed.
>>
>> The name “-Wgnu-variable-sized-type-not-at-end” was just used the warning name from CLANG. -:)
>>
>> Shall we use the same name as CLANG? Or we invent a new name?
>
> The latter IMHO. Having a warning with completely nonsensical name will
> just confuse users.
Okay. -:)
How about "-Wstruct-with-fam-not-at-end”? Or do you have any suggestion on the name?
>
>>> GNU variable sized type not at the end of a
>>> struct is something like
>>> void bar (void *);
>>> void foo (int n) {
>>> struct S { int a; int b[n]; int c; } s;
>>> s.a = 1;
>>> __builtin_memset (s.b, 0, sizeof (s.b));
>>> s.c = 3;
>>> bar (&s);
>>> }
>>> Certainly not flexible array members in the middle of structure.
>>
>> Right now, with -Wpedantic, we have the following warning for the above small case:
>>
>> t2.c:3:24: warning: a member of a structure or union cannot have a variably modified type [-Wpedantic]
>> 3 | struct S { int a; int b[n]; int c; } s;
>> | ^
>
> Sure, it is a GNU C extension (not allowed in C++ BTW).
> It is documented in https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
> though just very briefly:
> As an extension, GCC accepts variable-length arrays as a member of a structure or a union. For example:
> void
> foo (int n)
> {
> struct S { int x[n]; };
> }
Okay, I see.
>
>> Do we have a definition for “GNU variable sized type” now?
>
> Naturally, variable sized type should have non-constant sizeof, because
> otherwise it is constant sized type.
Oh, for flexible array members, we cannot take sizeof it, So they are considered as incomplete type, right?
thanks.
Qing
> That is not
> the case for flexible array members, there is nothing variable sized on
> them, especially if they are in the middle of a structure.
>
> Jakub
>
next prev parent reply other threads:[~2023-03-27 16:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 21:47 [V5][PATCH 0/2] Handle component_ref to a structure/union field including FAM for builtin_object_size Qing Zhao
2023-03-16 21:47 ` [V5][PATCH 1/2] Handle component_ref to a structre/union field including flexible array member [PR101832] Qing Zhao
2023-03-23 13:03 ` Fwd: " Qing Zhao
2023-03-23 18:55 ` Joseph Myers
2023-03-27 13:31 ` Qing Zhao
2023-03-27 14:22 ` Qing Zhao
2023-03-16 21:47 ` [V5][PATCH 2/2] Update documentation to clarify a GCC extension Qing Zhao
2023-03-23 13:05 ` Fwd: " Qing Zhao
2023-03-23 20:14 ` Joseph Myers
2023-03-27 13:38 ` Qing Zhao
2023-03-27 14:34 ` Xi Ruoyao
2023-03-27 15:37 ` Qing Zhao
2023-03-27 15:43 ` Jakub Jelinek
2023-03-27 15:57 ` Qing Zhao
2023-03-27 16:06 ` Jakub Jelinek
2023-03-27 16:22 ` Qing Zhao [this message]
2023-03-27 16:31 ` Jakub Jelinek
2023-03-27 16:48 ` Qing Zhao
2023-03-27 17:29 ` Qing Zhao
2023-03-23 13:02 ` Fwd: [V5][PATCH 0/2] Handle component_ref to a structure/union field including FAM for builtin_object_size Qing Zhao
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=E460392E-194F-47D9-9796-56F1E1E3D7F9@oracle.com \
--to=qing.zhao@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
--cc=keescook@chromium.org \
--cc=richard.guenther@gmail.com \
--cc=sandra@codesourcery.com \
--cc=siddhesh@gotplt.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).