1 /* PR c/51628.  */
2 /* { dg-do compile } */
3 /* { dg-options "-O" } */
4 
5 struct A {
6   int i;
7 } __attribute__ ((packed));
8 
9 int *
foo3(struct A * p1,int * q1,int * q2,struct A * p2)10 foo3 (struct A *p1, int *q1, int *q2, struct A *p2)
11 {
12   return (q1
13 	  ? &p1->i
14 /* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */
15 	  : (q2 ? &p2->i : q2));
16 /* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */
17 }
18 
19 int*
foo4(struct A * p1,int ** q1,int * q2,int * q3,struct A * p2)20 foo4 (struct A *p1, int **q1, int *q2, int *q3, struct A *p2)
21 {
22   return (q1
23 	  ? (*q1 = q2, &p1->i)
24 /* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */
25 	  : (q2
26 	     ? (*q1 = &p1->i,
27 /* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */
28 		*q2 = 2, &p2->i)
29 /* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */
30 	     : q2));
31 }
32