<div dir="ltr"><div dir="ltr">MSVC assigns the union a sizeof 4, and GCC assigns it a size of zero, and I think that's all there is to it:<div><a href="https://gcc.godbolt.org/z/1nhscrve9">https://gcc.godbolt.org/z/1nhscrve9</a></div><div><br></div><div>I think if you drill down, GCC is allowing this union to be zero-sized, but MSVC ensures that the size is non-zero, and then rounds the size up to alignment to get 4.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 10, 2021 at 9:58 AM Tal Shnaiderman <<a href="mailto:talshn@nvidia.com">talshn@nvidia.com</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">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_1899843063965151297WordSection1">
<p class="MsoNormal">Thank you for the information, any idea why this difference exists?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I only found this in C11:<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:5.4pt"><u></u> <u></u></p>
<p class="MsoNormal">“In most situations, the flexible array member is ignored. In particular, the size of the structure is as if the flexible array member were omitted except that it may have more trailing padding than the omission would imply”</p></div></div></blockquote><div><br></div><div>If ignoring the flexible array elements results in an empty record, the empty record would normally get a size of 1. GCC seems to have some special rules here that MSVC does not.</div></div></div>