Skip to content

Enabled -Wvla-extension by default in C++ compilation modes #62836

Closed
@AaronBallman

Description

@AaronBallman

Good or bad, Clang supports VLAs in C++ code. However, this comes as quite the surprise to users (https://ddanilov.me/default-non-standard-features/ among plenty of others) and there are more idiomatic alternatives that users should consider using in C++. I think we should enable -Wvla-extension by default in C++ so that users are made aware of this extension, especially given the security implications around stack overflows with VLAs that can be mitigated by heap allocations through C++ containers.

One challenge to this is that our existing warnings around VLAs and extensions are awkward and should be addressed: https://godbolt.org/z/eEnMsr4zG (we claim we're making a VLA as an extension and then saying nevermind, we decided to make it a constant array, also as an extension).

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions