[clang] [clang] Emit bad shift warnings (PR #70307)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 05:51:45 PDT 2024
AaronBallman wrote:
> This started to cause
>
> ```
> $ cat test.c
> #include <string.h>
> void f(void) {
> char a[strlen("x")];
> (void) a;
> }
> ```
>
> ```
> $ clang -Wall -fsyntax-only test.c
> test.c:3:12: warning: variable length array folded to constant array as an extension [-Wgnu-folding-constant]
> 3 | char a[strlen("x")];
> | ^~~~~~~~~~~
> 1 warning generated.
> ```
>
> to emit a warning, and I'm not sure that's intentional?
That is intentional; `strlen` is not a valid constant expression in C, and so that is technically a VLA, except we have an extension to fold it back into a constant.
https://github.com/llvm/llvm-project/pull/70307
More information about the cfe-commits
mailing list