List of ideas: n2660
-
arrays ...
-
array assignment
-
vectorized operations
-
Lengthof
-
0 size
-
VLA initialization
-
pointer to VLAs in structs
-
sizeof to VLA in prototype
-
-
flexible array member
- sizeof
- struct return, dereference
- with struct compatibility, structs with FAM could be incomplete
void foo(int i[3])
{
sizeof(i); // !
struct { int i; int x[]; } x;
sizeof(x); // !
}
variably modifed types become mandatory in C23
Multi-dimensional arrays can not be passed to functions expecting const-qualified arrays.
void transpose(int N, int M, double out[M][N], const double in[N][M]);
double a[2][2] = { ... };
double o[2][2];
transpose(2, 2, o, a); // passing 'a' not allowed
The problem is that the rules allowing assignment of pointers to some type to pointers to the qualified types do not work for pointer to arrays because it is only the element type that is qualified and not the array.
GCC: Commit
Related to this are also changes to how the tertiary operator behaves
Fixed: https://godbolt.org/z/6hE3z35fz Clang bug: llvm/llvm-project#54568
VLAs must be initialized in a loop, which is annoying and error prone. As part of general improvements to initialization this was fixed in C23
float a[N] = { };