public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/94558] New: Designated initializer inside _Generic is misinterpreted
@ 2020-04-11  7:49 elronnd at elronnd dot net
  2020-04-15 21:06 ` [Bug c/94558] " jsm28 at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: elronnd at elronnd dot net @ 2020-04-11  7:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94558

            Bug ID: 94558
           Summary: Designated initializer inside _Generic is
                    misinterpreted
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: elronnd at elronnd dot net
  Target Milestone: ---

POC:

typedef struct{int _;} A;
typedef struct{int _;} B;

typedef union {
        A a;
        B b;
} O;

#define NO(o) _Generic((o), \
        A: ((O){.a=o}), \
        B: ((O){.b=o}))

int main() {
        A a;
        O o = NO(a);
}


Generates the error message:

incompatible types when initializing type ‘int’ using type ‘A’ {aka ‘struct
<anonymous>’}

Because it's trying to initialize the '_' field in 'A' with 'a', instead of the
'a' field in 'O'.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-15 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11  7:49 [Bug c/94558] New: Designated initializer inside _Generic is misinterpreted elronnd at elronnd dot net
2020-04-15 21:06 ` [Bug c/94558] " jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).