gcc/testsuite/c-c++-common/alias-1.c
raw| 1 | /* PR c/111884 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-O2 -Wall" } */ |
| 4 | /* { dg-additional-options "-std=c++20" { target c++ } } */ |
| 5 | /* { dg-additional-options "-std=c23" { target c } } */ |
| 6 | |
| 7 | int f(int i) |
| 8 | { |
| 9 | int f = 1; |
| 10 | return i[(unsigned char *)&f]; |
| 11 | } |
| 12 | |
| 13 | int g(int i) |
| 14 | { |
| 15 | int f = 1; |
| 16 | return i[(signed char *)&f]; |
| 17 | } |
| 18 | |
| 19 | int h(int i) |
| 20 | { |
| 21 | int f = 1; |
| 22 | return i[(char *)&f]; |
| 23 | } |