cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

C99 variable-length arrays in C++

Open ilionsd opened this issue 8 months ago • 0 comments

Channel C++Weekly

Topics Why variable-length arrays are available in C++ as a compiler extension (why not part of standard and why not removed altogether). The good (they were added to C99 for some reason, right? Right?) The bad (sizeof becomes runtime) The ugly ( Lets say we have: template<typename T> struct S {}; How are we (and compiler supposer to interpret:

int arr[n];
S<decltype(arr)> s;

Well, the compiler disallows it. So we get "part of the language" that doesn't work with other part of the language )

Length Probably 5-10 minutes

ilionsd avatar May 13 '25 14:05 ilionsd