diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c b/gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c new file mode 100644 index 000000000..d3d93849b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/sh/pr64507.c @@ -0,0 +1,25 @@ +/* Check that the __builtin_strnlen returns 0 with with + non-constant 0 length. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern int snprintf(char *, int, const char *, ...); +extern void abort (void); + +int main() + { + int i; + int cmp = 0; + char buffer[1024]; + const char* s = "the string"; + + snprintf(buffer, 4, "%s", s); + + for (i = 1; i < 4; i++) + cmp += __builtin_strncmp(buffer, s, i - 1); + + if (cmp) + abort(); + + return 0; +} |