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

Eli Friedman eli.friedman at gmail.com
Wed Sep 11 12:30:53 PDT 2013


On Wed, Sep 11, 2013 at 6:10 AM, Matthew Curtis <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130911/02ad17d5/attachment.html>


More information about the cfe-dev mailing list