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

           Summary: Incorrect passing of values cast to union
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P5
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
   Estimated Hours: 0.0


When passing a value to a function expecting a union as its argument, it
appears that the compiler generates incorrect code so that what's seen inside
the function is not the value passed to the function.

Last tested using llvm and clang from svn trunk this morning, built on Debian
stable 32bit Intel.

The following code snippet demonstrates the issue:

#include    <stdio.h>

typedef union {
  int    i;
  void    *p;
} MyUnion;

static void f(MyUnion a)
{
  if (a.p == 0)
    printf("OK\n");
  else
    printf("Bad value: %p\n", a.p);
}

int
main()
{
  void    *a = 0;

  f((MyUnion)a);
  return(0);
}

-- 
Configure bugmail: http://www.llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are watching all bug changes.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to