Linux 5.18 Switches From Zero Length Arrays To Flexible Array Members
Back in 2020 the Linux kernel tried adding flexible array members to replace zero length arrays but that time the code was reverted shortly thereafter. For Linux 5.18 the tree-wide change of replacing zero length arrays with C99 flexible array members was merged and appears to be all in good shape this time.
Last week Gustavo Silva submitted the pull switching all zero length array usage over to flexible array members. The motivation is that flexible array members are more reliable than zero length arrays when it comes to calculating the size of the array, the compiler can better note potential issues, etc.
Flexible array members were standardized in C99 and with Linux 5.18 is the switch to C11 rather than C89 as the default C standard.
More details on the Linux kernel's deprecation of zero length arrays and usage of flexible array members via the kernel docs.
Last week Gustavo Silva submitted the pull switching all zero length array usage over to flexible array members. The motivation is that flexible array members are more reliable than zero length arrays when it comes to calculating the size of the array, the compiler can better note potential issues, etc.
Flexible array members were standardized in C99 and with Linux 5.18 is the switch to C11 rather than C89 as the default C standard.
More details on the Linux kernel's deprecation of zero length arrays and usage of flexible array members via the kernel docs.
10 Comments