[LLVMbugs] [Bug 1421] NEW: CopyAggregate doesn't play nice with unions

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue May 15 02:27:04 PDT 2007


           Summary: CopyAggregate doesn't play nice with unions
           Product: new-bugs
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr


struct A {
  char c;
  int i;

struct B {
  char c;
  unsigned char x;

union U { struct A a; struct B b; };

int check (void) {
  union U u, v;

  v.b.x = 0xff;
  u = v;
  return (u.b.x == 0xff);

Compiled with -O2:
        ret i32 0
Should return 1.  The point is that the union takes its fields
from struct A.  The second char x in struct B is in the empty
space (due to alignment) in struct A between char c and int i,
so is not copied when CopyAggregate copies by fields.  Copying
by fields is completely bogus with respect to unions of structs
unless every field in every union member is covered by an LLVM
field.  This cannot be done by converting only one union member,
as is done right now.

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list