| 1 |
/* { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* *-*-uclinux* } } */ |
| 2 |
/* { dg-options -O2 } */ |
| 3 |
|
| 4 |
#include <sys/types.h> |
| 5 |
#include <sys/mman.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
struct S { long x __attribute__((packed)); }; /* { dg-warning "attribute ignored" "" { target default_packed } } */ |
| 10 |
volatile long sink; |
| 11 |
|
| 12 |
void foo (struct S *s) |
| 13 |
{ |
| 14 |
sink = s->x; |
| 15 |
} |
| 16 |
|
| 17 |
int main () |
| 18 |
{ |
| 19 |
size_t ps = getpagesize (); |
| 20 |
char *ptr, *page; |
| 21 |
struct S *s; |
| 22 |
|
| 23 |
ptr = malloc (3*ps); |
| 24 |
page = (char *)(((__UINTPTR_TYPE__)ptr + (ps - 1)) & -ps); |
| 25 |
munmap (page + ps, ps); |
| 26 |
|
| 27 |
s = (struct S *)(page + ps - sizeof(struct S)); |
| 28 |
foo(s); |
| 29 |
|
| 30 |
return 0; |
| 31 |
} |