1/* Copyright (C) 2003 Free Software Foundation. 2 3 Test strcpy optimizations don't evaluate side-effects twice. 4 5 Written by Jakub Jelinek, June 23, 2003. */ 6 7typedef __SIZE_TYPE__ size_t; 8extern char *strcpy (char *, const char *); 9extern int memcmp (const void *, const void *, size_t); 10extern void abort (void); 11extern void exit (int); 12 13size_t 14test1 (char *s, size_t i) 15{ 16 strcpy (s, "foobarbaz" + i++); 17 return i; 18} 19 20size_t 21check2 (void) 22{ 23 static size_t r = 5; 24 if (r != 5) 25 abort (); 26 return ++r; 27} 28 29void 30test2 (char *s) 31{ 32 strcpy (s, "foobarbaz" + check2 ()); 33} 34 35int 36main (void) 37{ 38 char buf[10]; 39 if (test1 (buf, 7) != 8 || memcmp (buf, "az", 3)) 40 abort (); 41 test2 (buf); 42 if (memcmp (buf, "baz", 4)) 43 abort (); 44 exit (0); 45} 46