Testcase:
#include <stdio.h>
struct S { short x; };
typedef struct S __attribute__((__may_alias__)) test;
int f() {
int a=10;
test *p=(test *)&a;
test s={1};
*p=s;
return a;
}
int main() {
if (f() == 10)
__builtin_abort()
return 0;
}
-------
Even though the struct is not the same size as int, this should still work as
the struct is marked as may_alias so we get an aliasing set of 0.
--
Summary: [4.2 Regression] wrong code with may_alias and structs
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28807