> On Aug 31, 2022, at 3:29 PM, Joseph Myers <jos...@codesourcery.com> wrote:
> 
> On Wed, 31 Aug 2022, Qing Zhao via Gcc-patches wrote:
> 
>>> 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?
> 
> Flexible array members are supported in all C standard modes, since they 
> don't affect the semantics of any valid pre-C99 program (only make valid 
> programs that were previously erroneous).
> 
> With -std=c89 or -std=gnu89, -pedantic will give a warning "ISO C90 does 
> not support flexible array members" and -pedantic-errors will change that 
> to an error.

A little confused here…

With both -std=c89 and -std=gnu89, -pedantic will warning on “[]” (C99 flexible 
array member):

[opc@qinzhao-ol8u3-x86 ~]$ gcc -std=c89 t.c  -pedantic
t.c:5:7: warning: ISO C90 does not support flexible array members [-Wpedantic]
    5 |   int b[];
      |       ^
[opc@qinzhao-ol8u3-x86 ~]$ gcc -std=gnu89 t.c  -pedantic
t.c:5:7: warning: ISO C90 does not support flexible array members [-Wpedantic]
    5 |   int b[];
      |       ^

Does the above mean that -std=gnu89 does not support C99 flexible array member, 
 then

When -std=gnu89 + -fstrict-flex-array=3  (ONLY C99 flexible array member [] is 
treated as a valid flexible array) present together, 

It should be reasonable to issue warning on this?      (-fstrict-flex-arrays=3 
is not supported by GNU extension GNU89, ignored)

Right?

Qing




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

Reply via email to