Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/strlenopt-31.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* { dg-do run } */ /* { dg-options "-O2" } */ #include "strlenopt.h" __attribute__((noinline, noclone)) int bar (char *p1, const char *q) { strcpy (p1, "abcde"); char *p2 = strchr (p1, '\0'); strcpy (p2, q); char *p3 = strchr (p2, '\0'); memcpy (p3, "x", 2); return strlen (p1); } int main (void) { char buffer[10]; int res = bar (buffer, "foo"); if (strcmp (buffer, "abcdefoox") != 0 || res != 9) abort (); return 0; }