Linux 5.18 Switches From Zero Length Arrays To Flexible Array Members

Written by Michael Larabel in Linux Kernel on 29 March 2022 at 05:19 AM EDT. 10 Comments
LINUX KERNEL
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.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week