[LLVMbugs] [Bug 18726] New: Union not returned correctly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 4 07:08:40 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18726

            Bug ID: 18726
           Summary: Union not returned correctly
           Product: clang
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ishiura-compiler at ml.kwansei.ac.jp
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang 3.5 (based on LLVM 3.5svn) for x86_64 target miscompiles the following
code.

    $ cat error.c

    union U { long m0[3]; long double m1; };

    union U func(void)
    {
        union U x = {{1,1,1}};
        long y = x.m0[2];

        return x;
    }

    int main(void)
    {
        union U ret = func();
        if( ret.m0[1] != 1 ) { __builtin_abort(); }

        return 0;
    }

    $ clang error.c -O2

    $ ./a.out
    Abort trap: 6

The value of ret.m0[1] was 140734836113409 instead of 1.
There was no problem with an i686 target.

    $ clang -v
    clang version 3.5 (trunk 200763)
    Target: x86_64-apple-darwin13.0.0
    Thread model: posix

-- 
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/20140204/6b42bdf0/attachment.html>


More information about the llvm-bugs mailing list