Your code is invalid C ++.
However, it is valid C, a kind of. The standard way to write this to C is to declare the final element as T data[]; ("flexible length array"), and the goal is to allow you to allocate one separate dynamic memory block and store both a fixed header and a variable-length array in it together.
There are several restrictions on the use of this type (for example, it cannot be a type of an automatic variable or an array element). See, for example, the implementation of GCC , which offers several non-standard extensions.
source share