blob: 2ee75d9804adb706dd9c0f752090f9ef2d32a148 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* { dg-do run } */
/* { dg-options "-O3 -fno-strict-aliasing" } */
struct s { int x; } __attribute__((packed));
struct t { int x; };
void __attribute__((noinline,noipa))
swap(struct s* p, struct t* q)
{
p->x = q->x;
q->x = p->x;
}
int main()
{
struct t a[2];
a[0].x = 0x12345678;
a[1].x = 0x98765432;
swap ((struct s *)((char *)a + 1), a);
if (a[0].x != 0x12345678)
__builtin_abort ();
return 0;
}
|