PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / pr58346-1.c
blob70a16d12d97e86253c987747e3dd7e5045e85361
1 /* PR c/58346 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wno-c++-compat" { target c } } */
5 struct U {
6 #ifdef __cplusplus
7 char a[0];
8 #endif
9 };
10 static struct U b[6];
11 static struct U *u1, *u2;
13 int
14 foo (struct U *p, struct U *q)
16 return q - p; /* { dg-error "arithmetic on pointer to an empty aggregate" } */
19 void
20 bar (void)
22 __PTRDIFF_TYPE__ d = u1 - u2; /* { dg-error "arithmetic on pointer to an empty aggregate" } */
23 __asm volatile ("" : "+g" (d));
24 foo (&b[0], &b[4]);