diff options
Diffstat (limited to 'test/regression/struct12.c')
-rw-r--r-- | test/regression/struct12.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/regression/struct12.c b/test/regression/struct12.c new file mode 100644 index 00000000..39e62b28 --- /dev/null +++ b/test/regression/struct12.c @@ -0,0 +1,39 @@ +/* This is was originally a regression test for bug 43784 of gcc. + See ISO/IEC 9899:TC3 ยง6.8.6.4p4 and footnote 139. */ + +#include <stdio.h> + +struct s { + unsigned char a[256]; +}; +union u { + struct { struct s b; int c; } d; + struct { int c; struct s b; } e; +}; + +static union u v; +static struct s *p = &v.d.b; +static struct s *q = &v.e.b; + +static struct s __attribute__((noinline)) rp(void) +{ + return *p; +} + +static void qp(void) +{ + *q = rp(); +} + +int main() +{ + int i; + for (i = 0; i < 256; i++) + p->a[i] = i; + qp(); + for (i = 0; i < 256; i++) + if (q->a[i] != i) + printf("ERROR at %d: %d\n", i, q->a[i]); + return 0; +} + |