by fl0ki · 2y ago · 0 comments
I'm curious how these dynamics play out in less popular compilers. If a compiler implemented VLAs in C99, they almost certainly still have that feature for backwards compatibility even after they support C11.
Is there any compiler which appeared on the scene between C11 and C23, and during that window, chose not to support VLAs and thus C99? It's not like C11 itself was very widely adopted, precisely because of the long implementation and industry rollout windows.
For these reasons, we propose to make variably-modified types
mandatory in C23. VLAs with automatic storage duration remain an optional language
feature due to their higher implementation overhead and security concerns on some
implementations (i.e. when allocated on the stack and not using stack probing).
from N2778 (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2778.pdf)> Variable length arrays with automatic storage duration are a conditional feature that implementations need not support
confused
https://en.wikipedia.org/wiki/Variable-length_array#C99
If that phrasing isn't accurate I'm sure they'd appreciate an edit.
void example(int n) { printf("%zu", sizeof(int[n])); }
void example2(int n, int (*a)[n]) { }
This is optional: void example3(int n) { int x[n]; }