[PATCH] D135727: [clang] Correct sanitizer behavior in union FAMs

Kees Cook via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 19:19:38 PDT 2022


kees added a comment.

Change log typo? "but for all" should be "but not for all" ?



================
Comment at: clang/lib/AST/Expr.cpp:223
     // arrays to be treated as flexible-array-members, we still emit diagnostics
     // as if they are not. Pending further discussion...
+    if (StrictFlexArraysLevel == FAMKind::ZeroOrIncomplete && Size.uge(1))
----------------
Isn't this commit addressing this commit, and it can be removed?


================
Comment at: clang/test/CodeGen/bounds-checking-fam.c:13
+
+union Zero {
+  int a[0];
----------------
I think it might be better to make this a struct, and adjust it and the other to include a second member to avoid the C99 issues.

```
struct Zero {
    int ignored;
    int a[0];
};
```

Also, I think a "real" FAM should be included as well, since its behavior should always be the same, regardless of `-fstrict-flex-arrays`:

```
struct FAM {
    int ignored;
    int a[];
}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135727



More information about the cfe-commits mailing list