blob: e6a1b28670ac68c3110b8b6cf394269fc829e584 (
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
|
/* PR middle-end/41935 */
/* { dg-do run } */
/* { dg-options "-O2" } */
extern void abort (void);
struct A { int a; int b[10]; };
int
foo (struct A *p)
{
return __builtin_offsetof (struct A, b[p->a]);
}
int
main ()
{
struct A a;
a.a = 7;
if (foo (&a) != 7 * sizeof (int) + __builtin_offsetof (struct A, b))
abort ();
a.a = 2;
if (foo (&a) != 2 * sizeof (int) + __builtin_offsetof (struct A, b))
abort ();
return 0;
}
|