gcc/testsuite/gcc.dg/torture/pr120006.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-additional-options "-fipa-pta" } */ |
| 3 | |
| 4 | char *b; |
| 5 | int f = 1; |
| 6 | |
| 7 | char *xstrdup(char *i) { |
| 8 | char *c = __builtin_strdup(i); |
| 9 | if (!c) |
| 10 | __builtin_exit(1); |
| 11 | return c; |
| 12 | } |
| 13 | |
| 14 | int main() { |
| 15 | char g; |
| 16 | char h[8]; |
| 17 | |
| 18 | for (int i = 0; i < 2; i++) { |
| 19 | char c = *__builtin_strdup(""); |
| 20 | b = &g; |
| 21 | |
| 22 | if (f) { |
| 23 | h[0] = '-'; |
| 24 | h[1] = 'a'; |
| 25 | h[2] = '\0'; |
| 26 | b = xstrdup(h); |
| 27 | } |
| 28 | } |
| 29 | if (__builtin_strcmp(b, "-a") != 0) |
| 30 | __builtin_abort(); |
| 31 | } |