[llvm-bugs] [Bug 36050] New: Suspected bug on nested union type-punning

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 22 19:43:16 PST 2018


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

            Bug ID: 36050
           Summary: Suspected bug on nested union type-punning
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chen.pang.he at jdh8.org
                CC: llvm-bugs at lists.llvm.org

#define reinterpret(T, x) ((union { __typeof__(x) from; T to; }){ x }.to)

float fail(float x)
{
    // error: initializer element is not a compile-time constant
    return reinterpret(float, reinterpret(int, x) | 0x7FC00000);
}

float pass(float x)
{
    unsigned i = reinterpret(int, x);

    return reinterpret(int, i | 0x7FC00000);
}

-- 
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/20180123/c9852327/attachment.html>


More information about the llvm-bugs mailing list