https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836

--- Comment #35 from qinzhao at gcc dot gnu.org ---
(In reply to James Y Knight from comment #33)

> 
> I don't understand what the -Wstrict-flex-arrays warning and its multiple
> levels is proposed to actually do.
> 
> Is it supposed to warn on the structs that change behavior in the
> corresponding -fstrict-flex-array=LEVEL? But that would mean
> -Wstrict-flex-arrays=1 would warn on any array at the end of a struct which
> has a size other than 0 or 1. That's clearly not going to be actually
> practical...so perhaps you had something else in mind?


I think that -Wstrict-flex-arrays will need to be cooperated with
-fstrict-flex-arrays=N, i.e, only when -fstrict-flex-arrays=N is presenting,
-Wstrict-flex-arrays will be valid and report the warnings when see a [0], or
[1], or any trailing array based on N:

when -fstrict-flex-arrays
=0, -Wstrict-flex-arrays will NOT issue any warnings;
=1, -Wstrict-flex-arrays will issue warnings when an array ref's index is
larger than the upper bounds of a trailing array that is a regular trailing
array;
=2, -Wstrict-flex-arrays will issue warnings when an array ref's index is
larger than the upper bounds of a trailing array that is a regular trailing
array or [1];
=3, -Wstrict-flex-arrays will issue warnings when an array ref's index is
larger than the upper bounds of a trailing array that is a regular trailing
array or [1], or [0].

let me know if you have any comment and suggestion on this.

Reply via email to