[PATCH] D134902: [clang] Implement -fstrict-flex-arrays=3

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 10 22:35:26 PDT 2022


serge-sans-paille added a comment.

In D134902#3848246 <https://reviews.llvm.org/D134902#3848246>, @void wrote:

> @rsmith, @serge-sans-paille, and @kees, I need some advice. There's a test in `clang/test/CodeGen/bounds-checking.c` that's checking bounds stuff on unions. The behavior is...weird to me. It says that an array of 0 or 1 is a FAM, but one larger is not (see below). That seems counter to how structs are handled. If this is true, then the check in `clang/lib/AST/Expr.cpp` also needs to be updated...

I second the opinion here. C99 says nothing about flexible array member for unions, that's already a "language extension". (and so not be considered as FAM by `-fstrict-flex-arrays=3`)
Both GCC and Clang implement that extension for array of size 0 and 1, see https://godbolt.org/z/1xYMYq75s.

We may want to harmonize with struct behavior (for consistency etc) but I'd advocate to so in a separate patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134902/new/

https://reviews.llvm.org/D134902



More information about the cfe-commits mailing list