blob: 7ff03e85ceaf0f125c46327ff6c9bf900e0b82db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* PR c/51628. */
/* { dg-do compile } */
/* { dg-options "-O" } */
void foo (int *);
int *
bar (int n, int k, void *ptr)
{
struct A
{
char c[k];
int x[n];
} __attribute__ ((packed));
struct A *p = (struct A *) ptr;
int *p0, *p1;
p0 = p->x;
/* { dg-warning "may result in an unaligned pointer value" "" { target *-*-* } .-1 } */
foo (p0);
p1 = &p->x[1];
/* { dg-warning "may result in an unaligned pointer value" "" { target *-*-* } .-1 } */
foo (p1);
return &p->x[1];
/* { dg-warning "may result in an unaligned pointer value" "" { target *-*-* } .-1 } */
}
|