gcc/testsuite/gcc.c-torture/execute/mayalias-1.c
raw| 1 | /* Tests that the may_alias attribute works as expected. |
| 2 | Author: Osku Salerma <[email protected]> Apr 2002. */ |
| 3 | |
| 4 | extern void abort(void); |
| 5 | extern void exit(int); |
| 6 | |
| 7 | typedef short __attribute__((__may_alias__)) short_a; |
| 8 | |
| 9 | int |
| 10 | main (void) |
| 11 | { |
| 12 | int a = 0x12345678; |
| 13 | short_a *b = (short_a*) &a; |
| 14 | |
| 15 | b[1] = 0; |
| 16 | |
| 17 | if (a == 0x12345678) |
| 18 | abort(); |
| 19 | |
| 20 | exit(0); |
| 21 | } |