public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: "Joseph@codesourcery.com" <Joseph@codesourcery.com>
Cc: jakub Jelinek <jakub@redhat.com>,
	richard Biener <rguenther@suse.de>,
	Kees Cook <keescook@chromium.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>,
	Nathan Sidwell <Nathan@acm.org>, martin Sebor <msebor@gmail.com>
Subject: Re: [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array
Date: Wed, 31 Aug 2022 19:24:41 +0000	[thread overview]
Message-ID: <CBB2F281-8657-4AA5-BA85-0835B42540DD@oracle.com> (raw)
In-Reply-To: <B92A4442-0B40-4C62-A725-FCC8176A00F3@oracle.com>



> On Aug 31, 2022, at 2:55 PM, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> 
> 
>> On Aug 31, 2022, at 1:21 PM, Joseph Myers <joseph@codesourcery.com> wrote:
>> 
>> On Wed, 31 Aug 2022, Qing Zhao via Gcc-patches wrote:
>> 
>>>> "a GNU extension" suggests a particular language feature, but I think 
>>>> you're actually referring here to a whole language version rather than an 
>>>> individual feature.
>>> 
>>> Is “not supported by GNU extension GNU89” better?
>> 
>> There are no existing diagnostics referring to GNU89 at all.  I don't 
>> think "GNU extension" needs to be mentioned in that diagnostic, but I also 
>> think that having that diagnostic at all is ill-conceived.
>> 
>>>> In any case, -std=gnu89 supports flexible array members.
>>> 
>>> Yes, but only [0],[1] are supported as flexible array members.  The C99 
>>> flexible array member [] is not supported by GNU89, right?
>> 
>> C99 flexible array members are fully supported in GNU89 mode.  In general, 
>> any feature from a new language version that doesn't affect code that was 
>> valid in previous versions is likely to be accepted as an extension with 
>> options for older language versions.
> 
> 
> We have a previous discussion on this: (https://gcc.gnu.org/pipermail/gcc-patches/2022-July/599067.html)
> 
> And looks like that the previous conclusion was wrong… please see the following:
> 
> ======
> 
>> How is level 3 (thus -fstrict-flex-array) interpreted when you specify 
>> -std=c89?  How for -std=gnu89?
> 
> 1. what’s the major difference between -std=c89 and -std=gnu89 on flexible array? (Checked online, cannot find a concrete answer on this).
> 	** my understanding is:   -std=c89 will not support any flexible array (neither [], [0], [1]), but -std=gnu89 will support [0] and [1], but not [].
>        Is this correct?
> 
> If my answer to the first question is correct, then:
> 
> 2. When -fstrict-flex-array=n and -std=c89 present at the same time, which one has the higher priority? 
>    	** I think that -std=c89 should be honored over -fstrict-flex-array, therefore we should disable -fstrict-flex-array=n when n > 0  and issue warnings to the user.
> 
> 
> 3. how about -fstrict-flex-array=n and -std=gnu89 present at the same time? 
>    	** When -std=gnu89 present, [] is not supported. So, we need to issue an warning to disable -fstrict-flex-array=3; but level 1 and level 2 is Okay.
> 
> We also need to document the above.
> ====
> 
> So, from my understanding from what you said so far, 
> 
> -std=c89 will not support any flexible array (neither [], [0], [1]),  but -std=gnu89 will support ALL flexible array including [0], [1], and [].
> 
> Is this understanding correct?

And also for C++:

-std=c++98 will not support any flexible array, but -std=gnu++98 will support ALL flexible array ([0],[1].[])?

Qing
> 
> thanks.
> 
> Qing
> 
> 
>> 
>> -- 
>> Joseph S. Myers
>> joseph@codesourcery.com


  reply	other threads:[~2022-08-31 19:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 14:40 Qing Zhao
2022-08-17 14:40 ` [[GCC13][Patch][V3] 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836] Qing Zhao
2022-08-26  8:49   ` Richard Biener
2022-08-26 13:37     ` Qing Zhao
2022-08-26  8:48 ` [[GCC13][Patch][V3] 1/2] Add a new option -fstrict-flex-array[=n] and new attribute strict_flex_array Richard Biener
2022-08-26 13:47   ` Qing Zhao
2022-08-29  8:04     ` Richard Biener
2022-08-30 20:30 ` Fwd: " Qing Zhao
2022-08-30 20:30   ` Qing Zhao
2022-08-30 22:53   ` Joseph Myers
2022-08-31 14:00     ` Qing Zhao
2022-08-31 17:21       ` Joseph Myers
2022-08-31 17:21         ` Joseph Myers
2022-08-31 18:55         ` Qing Zhao
2022-08-31 19:24           ` Qing Zhao [this message]
2022-08-31 19:29           ` Joseph Myers
2022-08-31 19:29             ` Joseph Myers
2022-08-31 19:47             ` Qing Zhao
2022-08-31 19:52               ` Joseph Myers
2022-08-31 20:06                 ` Qing Zhao
2022-08-31 20:09                   ` Joseph Myers
2022-08-31 20:16                     ` Qing Zhao
2022-08-31 20:35                       ` Qing Zhao
2022-08-31 22:23                         ` Kees Cook
2022-09-01  6:11                           ` Richard Biener
2022-09-04 14:17                             ` Qing Zhao
2022-08-31 22:17                       ` Kees Cook

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=CBB2F281-8657-4AA5-BA85-0835B42540DD@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=Joseph@codesourcery.com \
    --cc=Nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=keescook@chromium.org \
    --cc=msebor@gmail.com \
    --cc=rguenther@suse.de \
    /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).