[Bug middle-end/101836] __builtin_object_size(P->M, 1) where M is an array and the last member of a struct fails

foom at fuhm dot net gcc-bugzilla@gcc.gnu.org
Sat Jun 25 00:52:05 GMT 2022


James Y Knight <foom at fuhm dot net> changed:

           What    |Removed                     |Added
                 CC|                            |foom at fuhm dot net

--- Comment #31 from James Y Knight <foom at fuhm dot net> ---
It doesn't make sense to have a mode in which `int array[0]` is accepted but is
not a flex array.

Either that should be a compilation error (as the standard specifies), or it
should be a flex array. Accepting it as an extension but having it do the wrong
thing is not useful or helpful.

Note that Clang has a dedicated warning flag for zero-length arrays:
-Wzero-length-array, so anyone who wants to prohibit them may use
-Werror=zero-length-array. It would be helpful for GCC could follow suit there.

The other proposed modes:
- Treat all trailing arrays as flexible arrays. the default behavior;
- Only treating [], [0], and [1] as flexible array;
- Only treating [] and [0] as flexible array;
do make sense.

More information about the Gcc-bugs mailing list