gcc/testsuite/gcc.c-torture/execute/pr17252.c
raw| 1 | /* PR 17252. When a char * pointer P takes its own address, storing |
| 2 | into *P changes P itself. */ |
| 3 | |
| 4 | void abort (void); |
| 5 | |
| 6 | char *a; |
| 7 | |
| 8 | int |
| 9 | main (void) |
| 10 | { |
| 11 | /* Make 'a' point to itself. */ |
| 12 | a = (char *)&a; |
| 13 | |
| 14 | /* Change what 'a' is pointing to. */ |
| 15 | a[0]++; |
| 16 | |
| 17 | /* If a's memory tag does not contain 'a' in its alias set, we will |
| 18 | think that this predicate is superfluous and change it to |
| 19 | 'if (1)'. */ |
| 20 | if (a == (char *)&a) |
| 21 | abort (); |
| 22 | |
| 23 | return 0; |
| 24 | } |