https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110848

--- Comment #6 from Aaron Ballman <aaron at aaronballman dot com> ---
(In reply to Andrew Pinski from comment #4)
> Maybe my issue is this has been a documented extension for 20 years now.

Which is totally fair -- we don't usually enable congratulatory diagnostics by
default.

> -pedantic or -std=c++NN has always rejected it like it should. GCC has other
> extensions which folks could use by accident too (like statement
> expressions). Why is VLA special here?

FWIW, I can't honestly say I've ever seen someone use a statement expression
accidentally, though I believe it's possible to do so if you work hard enough
at it. That said, I think misuse of accidental VLAs has more opportunity for
poor security behavior (specifically around attacker-controllable stack usage)
than for statement expressions. Given the security concerns coupled with the
ease of accidental usage, I think VLAs *are* different than statement
expressions. Some supporting evidence of the confusion in the wild:

https://stackoverflow.com/questions/70912167/how-do-i-tell-if-i-am-using-vla-variable-length-array
https://stackoverflow.com/questions/39334435/variable-length-array-vla-in-c-compilers
https://ddanilov.me/default-non-standard-features/
https://meta.stackoverflow.com/questions/376955/what-should-i-do-when-an-op-uses-variable-length-arrays-vlas-in-c
https://cplusplus.com/forum/beginner/284866/

(Granted, there's confusion about *everything* in C and C++.)

It's worth noting that -std=c++NN does *not* reject use of VLAs; you have to
pass -pedantic or -Wvla to get the diagnostic: https://godbolt.org/z/PGorTYG7r

Reply via email to