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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to