[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays
Martin Sebor via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 29 07:39:34 PDT 2022
msebor added a comment.
In D126864#3616524 <https://reviews.llvm.org/D126864#3616524>, @serge-sans-paille wrote:
> GCC and Clang don't have the same behavior wrt. macros-as-abound and standard-layout-requirement, see https://godbolt.org/z/3vc4TcTYz
> I'm fine with keeping the CLang behavior, but do we want to keep it only for level=0, and drop it for higher level (this would look odd to me).
If you're referring to the warning, GCC needs `-O2` to issue most instances of `-Warray-bounds`. The warning also treats one-element trailing arrays as flexible array members, so it's intentionally silent about the test case. GCC should update the warning to reflect the `-fstrict-flex-arrays=N` level. (Macros are long expanded by the time the code reaches the middle end so they don't come into play, except perhaps when they come from system headers.)
CHANGES SINCE LAST ACTION
More information about the cfe-commits