2002-05-10 David S. Miller <davem@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / string-opt-17.c
blob47fe42db62865716ff137d0a64c20c76c9cd351f
1 /* Copyright (C) 2002 Free Software Foundation.
3 Ensure that builtin memset operations for constant length and
4 non-constant assigned value don't cause compiler problems.
6 Written by Roger Sayle, 21 April 2002. */
8 extern void abort (void);
9 typedef __SIZE_TYPE__ size_t;
10 extern void *memset (void *, int, size_t);
12 char buffer[32];
14 int
15 main (int argc)
17 memset (buffer, argc, 0);
18 memset (buffer, argc, 1);
19 memset (buffer, argc, 2);
20 memset (buffer, argc, 3);
21 memset (buffer, argc, 4);
22 memset (buffer, argc, 5);
23 memset (buffer, argc, 6);
24 memset (buffer, argc, 7);
25 memset (buffer, argc, 8);
26 memset (buffer, argc, 9);
27 memset (buffer, argc, 10);
28 memset (buffer, argc, 11);
29 memset (buffer, argc, 12);
30 memset (buffer, argc, 13);
31 memset (buffer, argc, 14);
32 memset (buffer, argc, 15);
33 memset (buffer, argc, 16);
34 memset (buffer, argc, 17);
36 return 0;
39 #ifdef __OPTIMIZE__
40 /* When optimizing, most of the above cases should be transformed into
41 something else. So any remaining calls to the original function
42 for short lengths should abort. */
43 static void *
44 memset (void *dst, int c, size_t len)
46 if (len < 2)
47 abort ();
49 #endif