typedef int T[n];
is the essence of VLA-ness, not `int A[n]`. The array of VLA type can have any kind of storage one wants. T a;
It can be heap T *a = malloc(sizeof *a);
It can be even infamous alloca() T *a = alloca(sizeof *a);
Please stop talking about this "VLA is stack-base vector" crap because it means that one does not understand what VLAs are about. I admin that automatic VLAs are pretty much always wrong but this use case is a tiny bit of the realy functionality of VLA types. float A[n][n];
- allocation on heap float (*A)[n] = malloc(sizeof(int[n][n]));
...
free(A);
- indexing A[i][j]
- passing to functions: void add(int n, float A[static n][n], float B[static n][n], float RES[restrict static n][n]);
...
Please show me something as simple, effective, self-documenting and elegant in C++.
Also has no protection.