[PATCH] D76096: [clang] allow const structs to be constant expressions for C
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 12:35:41 PDT 2023
efriedma added inline comments.
================
Comment at: clang/test/Sema/builtins.c:181-186
+ ASSERT(!OPT(test17_c));
+ ASSERT(!OPT(&test17_c[0]));
+ ASSERT(!OPT((char*)test17_c));
ASSERT(!OPT(test17_d)); // expected-warning {{folding}}
ASSERT(!OPT(&test17_d[0])); // expected-warning {{folding}}
ASSERT(!OPT((char*)test17_d)); // expected-warning {{folding}}
----------------
nickdesaulniers wrote:
> `test17_c` and `test17_d` are both declared as `const char [4];` not sure why this case would differ
`strlen(test17_c)` is 3; `strlen(test17_d)` is undefined behavior. I assume the difference is because the latter doesn't fold.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76096/new/
https://reviews.llvm.org/D76096
More information about the cfe-commits
mailing list