| 1 |
/* PR tree-optimization/90989 - incorrrect strlen result after second strcpy |
| 2 |
into the same destination. |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
// #include "strlenopt.h" |
| 7 |
|
| 8 |
char a[4]; |
| 9 |
|
| 10 |
int f4 (void) |
| 11 |
{ |
| 12 |
char b[4]; |
| 13 |
__builtin_strcpy (b, "12"); |
| 14 |
|
| 15 |
int i = __builtin_strcmp (a, b); |
| 16 |
|
| 17 |
__builtin_strcpy (b, "123"); |
| 18 |
if (__builtin_strlen (b) != 3) |
| 19 |
__builtin_abort (); |
| 20 |
|
| 21 |
return i; |
| 22 |
} |
| 23 |
|
| 24 |
int f6 (void) |
| 25 |
{ |
| 26 |
char b[6]; |
| 27 |
__builtin_strcpy (b, "1234"); |
| 28 |
|
| 29 |
int i = __builtin_strcmp (a, b); |
| 30 |
|
| 31 |
__builtin_strcpy (b, "12345"); |
| 32 |
if (__builtin_strlen (b) != 5) |
| 33 |
__builtin_abort (); |
| 34 |
|
| 35 |
return i; |
| 36 |
} |
| 37 |
|
| 38 |
int f8 (void) |
| 39 |
{ |
| 40 |
char b[8]; |
| 41 |
__builtin_strcpy (b, "1234"); |
| 42 |
|
| 43 |
int i = __builtin_strcmp (a, b); |
| 44 |
|
| 45 |
__builtin_strcpy (b, "1234567"); |
| 46 |
if (__builtin_strlen (b) != 7) |
| 47 |
__builtin_abort (); |
| 48 |
|
| 49 |
return i; |
| 50 |
} |
| 51 |
|
| 52 |
/* { dg-final { scan-tree-dump-times "abort|strlen" 0 "optimized" } } */ |