<div dir="ltr">In this instance, clang appears to be doing MSVC-compatible struct layout. See these examples on godbolt:<div><a href="https://gcc.godbolt.org/z/3W47nTh8Y">https://gcc.godbolt.org/z/3W47nTh8Y</a><br></div><div><br></div><div>MSVC will make this struct 8 bytes, GCC makes it 4. Clang follows suit depending on the target, *-windows-gnu or *-windows-msvc. That seems like intended behavior.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 7, 2021 at 1:56 PM Tal Shnaiderman via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
I hope this is the right forum for the question below.<br>
<br>
In the DPDK project we're using clang as the compiler on Windows.<br>
<br>
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.<br>
<br>
e.g.<br>
<br>
struct umr {<br>
        uint32_t temp;<br>
        union {<br>
                uint32_t res_dp[0];<br>
                uint32_t res_dp2[0];<br>
        };<br>
};<br>
<br>
On linux with GCC the result of <br>
<br>
sizeof(struct umr) = 4<br>
<br>
When on Windows with clang 11.0.0 I'm getting <br>
<br>
sizeof(struct umr) = 8<br>
<br>
Is this a bug? or flexible array members in a union behavior is undefined?<br>
<br>
Thanks<br>
<br>
Tal Shnaiderman.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>