[cfe-dev] question about initializing multiple members of unions

Matthew Curtis mcurtis at codeaurora.org
Thu Sep 12 14:04:47 PDT 2013


On 9/11/2013 2:30 PM, Eli Friedman wrote:
> On Wed, Sep 11, 2013 at 6:10 AM, Matthew Curtis 
> <mcurtis at codeaurora.org <mailto:mcurtis at codeaurora.org>> wrote:
>
>     I'm investigating an assert in clang compiling the following code:
>
>       typedef union {
>         struct {
>           int zero;
>           int one;
>           int two;
>           int three;
>         } a;
>         int b[4];
>       } my_agg_t;
>
>       my_agg_t agg_instance =
>       {
>         .b[0] = 0,
>         .a.one = 1,
>         .b[2] = 2,
>         .a.three = 3,
>       };
>
>     I'm a little uncertain as to what this *should* do.
>
> This is also http://llvm.org/bugs/show_bug.cgi?id=16644 .
>
> I would say we should either use gcc's interpretation or reject it.
>
> -Eli

Sounds reasonable. Unless someone has a dissenting opinion, I'll look at 
fixing this by making clang consistent with gcc.

Thanks,
Matthew Curtis

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130912/70ff379d/attachment.html>


More information about the cfe-dev mailing list