| 1 |
/* PR c/58346 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-Wno-c++-compat" { target c } } */ |
| 4 |
|
| 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; |
| 12 |
|
| 13 |
int |
| 14 |
foo (struct U *p, struct U *q) |
| 15 |
{ |
| 16 |
return q - p; /* { dg-error "arithmetic on pointer to an empty aggregate" } */ |
| 17 |
} |
| 18 |
|
| 19 |
void |
| 20 |
bar (void) |
| 21 |
{ |
| 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]); |
| 25 |
} |