[LLVMbugs] [Bug 6386] New: Incorrect passing of values cast to union

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 22 04:38:43 PST 2010


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: unassignedclangbugs at nondot.org
        ReportedBy: richard at tiptree.demon.co.uk
                CC: llvmbugs at cs.uiuc.edu
   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.



More information about the llvm-bugs mailing list