1 /* { dg-do compile } */ 2 /* { dg-options "-O2" } */ 3 /* { dg-additional-options "-minline-stringops-dynamically" { target { i?86-*-* x86_64-*-* } } } */ 4 5 extern void abort (void); 6 7 #define MAX_OFFSET (sizeof (long long)) 8 #ifndef MAX_COPY 9 #define MAX_COPY (1024 + 8192) 10 #endif 11 #define MAX_EXTRA (sizeof (long long)) 12 13 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA) 14 15 static union { 16 char buf[MAX_LENGTH]; 17 long long align_int; 18 long double align_fp; 19 } u; 20 21 char A[MAX_LENGTH]; 22 23 int main()24main () 25 { 26 int off, len, i; 27 char *p, *q; 28 29 for (i = 0; i < MAX_LENGTH; i++) 30 A[i] = 'A'; 31 32 for (off = 0; off < MAX_OFFSET; off++) 33 for (len = 1; len < MAX_COPY; len++) 34 { 35 for (i = 0; i < MAX_LENGTH; i++) 36 u.buf[i] = 'a'; 37 38 p = __builtin_memcpy (u.buf + off, A, len); 39 if (p != u.buf + off) 40 abort (); 41 42 q = u.buf; 43 for (i = 0; i < off; i++, q++) 44 if (*q != 'a') 45 abort (); 46 47 for (i = 0; i < len; i++, q++) 48 if (*q != 'A') 49 abort (); 50 51 for (i = 0; i < MAX_EXTRA; i++, q++) 52 if (*q != 'a') 53 abort (); 54 } 55 56 return 0; 57 } 58