llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.93k stars 11.53k forks source link

`-Wvla-cxx-extension` does not produce an error with `-Wall -pedantic-errors` #99725

Open zygoloid opened 1 month ago

zygoloid commented 1 month ago

Testcase:

int f();
void g() {
  int arr[f()];
}

Compiling this invalid code in C++ mode with -Wall -pedantic-errors should give an error. But it doesn't, it just produces a warning.

It seems that the fact that -Wvla-cxx-extension is in -Wall is breaking -pedantic-errors. Replacing -pedantic-errors with -Werror=pedantic works properly, which is odd since -pedantic-errors is supposed to imply -Werror=pedantic.

(Including this warning in -Wall seems like a strange choice; it's not in GCC's -Wall and doesn't seem like the kind of thing that -Wall usually warns about.)

AaronBallman commented 1 month ago

The decision to add this to -Wall and deviate from GCC was explicit: https://discourse.llvm.org/t/rfc-diagnosing-use-of-vlas-in-c/73109

But you're right that -pedantic-errors should catch this and it's not: https://godbolt.org/z/Mh4oKb8rf

AaronBallman commented 1 month ago

This regressed between Clang 17 and Clang 18 as a result of 84a3aadf0f2483dde0acfc4e79f2a075a5f35bd1 (7339c0f782d5c70e0928f8991b0c05338a90c84c)