diff options
author | Richard Henderson <rth@gcc.gnu.org> | 2004-11-08 10:53:59 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2004-11-08 10:53:59 -0800 |
commit | 513305f1598cc0bbb73e892e4d272a592f2d08c3 (patch) | |
tree | 043363f7b590168825ebdfa4db7b7fad25f1b010 | |
parent | 5e74a4ebf70eae09241e779146d3c94f03d0679e (diff) | |
download | gcc-513305f1598cc0bbb73e892e4d272a592f2d08c3.zip gcc-513305f1598cc0bbb73e892e4d272a592f2d08c3.tar.gz gcc-513305f1598cc0bbb73e892e4d272a592f2d08c3.tar.bz2 |
New test case.
From-SVN: r90280
-rw-r--r-- | gcc/testsuite/gcc.dg/20041106-1.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/20041106-1.c b/gcc/testsuite/gcc.dg/20041106-1.c new file mode 100644 index 0000000..538f2dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/20041106-1.c @@ -0,0 +1,31 @@ +/* { dg-do run { target *-*-linux* *-*-solaris* } } */ +/* { dg-options -O2 } */ + +#include <sys/types.h> +#include <sys/mman.h> +#include <unistd.h> +#include <stdlib.h> + +struct S { long x __attribute__((packed)); }; +volatile long sink; + +void foo (struct S *s) +{ + sink = s->x; +} + +int main () +{ + size_t ps = getpagesize (); + char *ptr, *page; + struct S *s; + + ptr = malloc (3*ps); + page = (char *)(((size_t)ptr + (ps - 1)) & -ps); + munmap (page + ps, ps); + + s = (struct S *)(page + ps - sizeof(struct S)); + foo(s); + + return 0; +} |