[cfe-dev] Flexible array members in a union
Tal Shnaiderman via cfe-dev
cfe-dev at lists.llvm.org
Tue Sep 7 13:56:28 PDT 2021
Hello,
I hope this is the right forum for the question below.
In the DPDK project we're using clang as the compiler on Windows.
I noticed that there is a size difference between a Windows and a Linux if flexible array members are defined in a union inside a struct.
e.g.
struct umr {
uint32_t temp;
union {
uint32_t res_dp[0];
uint32_t res_dp2[0];
};
};
On linux with GCC the result of
sizeof(struct umr) = 4
When on Windows with clang 11.0.0 I'm getting
sizeof(struct umr) = 8
Is this a bug? or flexible array members in a union behavior is undefined?
Thanks
Tal Shnaiderman.
More information about the cfe-dev
mailing list