[PATCH] D132944: [clang] cleanup -fstrict-flex-arrays implementation

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 11:49:25 PDT 2022


jyknight added inline comments.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:910
       if (FD->getParent()->isUnion())
-        return StrictFlexArraysLevel < 2;
+        return true;
       RecordDecl::field_iterator FI(
----------------
This is a functional change (which is good, but the commit message needs to be adjusted). In current trunk
```
union X { int x[0]; };
int foo(X*x) { return x->x[2]; }
```
built with `-fstrict-flex-arrays=2 -fsanitize=array-bounds` would incorrectly report ubsan error, and this change fixes that.

I think this testcase can be added to clang/test/CodeGen/bounds-checking-fam.c. Probably this should also be nominated for backport to the 15.x branch (for the first point release I expect)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132944



More information about the cfe-commits mailing list