Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 1.01 KB

vla.md

File metadata and controls

24 lines (20 loc) · 1.01 KB

What Is a VLA And Why Is It 'Bad'?

A Variable Length Array (VLA) is an array where the size is not constant and depends on a variable.

VLAs have poor compiler support and can lead to inefficient code. The core issue with VLAs is that the compiler doesn't know the size of the stack frame. Without warning flags like -Wvla (Note: -Wvla is not turned on by -Wall nor any other warning flag) it can be easy to create a VLA by accident, even in C++ with some compilers.

Compiler Support

?inline ✅ available since C99
⛔ not available in C++ at all
⛔ was never supported by MSVC
⚠ optional feature since C11
⚠ supported as non-standard extension by GCC, clang

See Also

?inline <:stackoverflow:874353689031233606> What technical disadvantages do C99-style VLAs have?
<:stackoverflow:874353689031233606> What's the point of VLA anyway?