Skip to content

llvm-gcc PaddingElement optimization results in valid fields not being copied #1791

@llvmbot

Description

@llvmbot
Bugzilla Link 1419
Resolution FIXED
Resolved on Feb 22, 2010 12:50
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @lattner

Extended Description

Test case:

struct A {
short x;
long long :0;
};

struct B {
char a;
char b;
unsigned char i;
};

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

int check(void) {
union X x, y;

y.b.i = 0xff;
x = y;
return (x.b.i == 0xff);
}

When compiled with -O2:

define i32 @​check() {
entry:
ret i32 0
}

It should return 1. This is because the X.i field is not
being copied by the aggregate copy, since it lives inside
the padding of struct A.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions