> On Aug 31, 2022, at 1:21 PM, Joseph Myers <jos...@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?

thanks.

Qing


> 
> -- 
> Joseph S. Myers
> jos...@codesourcery.com

Reply via email to