Hi,
On 2023-02-06 11:55:40 -0500, Tom Lane wrote:
> I am, however, very dubious that Andres is correct that there's a
> problem here. Given that two of the variants of union NumericChoice
> are structs ending with a flexible array, any compiler that thinks
> it knows the size of the union precisely is broken.
The compiler just complains about the minimum size of the union, which is
Max(offsetof(NumericShort, n_data), offsetof(NumericLong, n_data))
IOW, our trickery with flexible arrays would allow us to allocate just 8 bytes
for a NumericData, but not just 6.
Flexible arrays allow the compiler to understand the variable size, but we
don't use it for all variability. Hence the warnings.
Greetings,
Andres Freund