[llvm-bugs] [Bug 45540] New: Designated initializer inside _Generic is misinterpreted

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 14 13:28:23 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45540

            Bug ID: 45540
           Summary: Designated initializer inside _Generic is
                    misinterpreted
           Product: clang
           Version: 9.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: elronnd at elronnd.net
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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 following error message:

t.c:15:18: error: initializing 'int' with an expression of incompatible type
'A'
        O o = NO(a);
                 ^
t.c:11:20: note: expanded from macro 'NO'
        B: ((O){.b=o}))

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200414/7293b7ac/attachment.html>


More information about the llvm-bugs mailing list