* expmed.c (flip_storage_order): Deal with complex modes specially.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / strcpy-1.c
blob9484e95d922b61c9598acc14abab67d48094a411
1 /* Copyright (C) 2002 Free Software Foundation.
3 Test strcpy with various combinations of pointer alignments and lengths to
4 make sure any optimizations in the library are correct. */
6 #include <string.h>
8 #ifndef MAX_OFFSET
9 #define MAX_OFFSET (sizeof (long long))
10 #endif
12 #ifndef MAX_COPY
13 #define MAX_COPY (10 * sizeof (long long))
14 #endif
16 #ifndef MAX_EXTRA
17 #define MAX_EXTRA (sizeof (long long))
18 #endif
20 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)
22 /* Use a sequence length that is not divisible by two, to make it more
23 likely to detect when words are mixed up. */
24 #define SEQUENCE_LENGTH 31
26 static union {
27 char buf[MAX_LENGTH];
28 long long align_int;
29 long double align_fp;
30 } u1, u2;
32 main ()
34 int off1, off2, len, i;
35 char *p, *q, c;
37 for (off1 = 0; off1 < MAX_OFFSET; off1++)
38 for (off2 = 0; off2 < MAX_OFFSET; off2++)
39 for (len = 1; len < MAX_COPY; len++)
41 for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)
43 u1.buf[i] = 'a';
44 if (c >= 'A' + SEQUENCE_LENGTH)
45 c = 'A';
46 u2.buf[i] = c;
48 u2.buf[off2 + len] = '\0';
50 p = strcpy (u1.buf + off1, u2.buf + off2);
51 if (p != u1.buf + off1)
52 abort ();
54 q = u1.buf;
55 for (i = 0; i < off1; i++, q++)
56 if (*q != 'a')
57 abort ();
59 for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)
61 if (c >= 'A' + SEQUENCE_LENGTH)
62 c = 'A';
63 if (*q != c)
64 abort ();
67 if (*q++ != '\0')
68 abort ();
69 for (i = 0; i < MAX_EXTRA; i++, q++)
70 if (*q != 'a')
71 abort ();
74 exit (0);