libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr109609.c
blob0e191cd1ee812719ad4d4f2604ff17bdced2f41b
1 /* { dg-do run } */
3 #define N 23
4 #define MAX_LEN 13
5 char dst[N + 1];
7 void __attribute__((noipa))
8 invert(const char *id)
10 char buf[MAX_LEN];
11 char *ptr = buf + sizeof(buf); // start from the end of buf
12 *(--ptr) = '\0'; // terminate string
13 while (*id && ptr > buf) {
14 *(--ptr) = *(id++); // copy id backwards
16 __builtin_strncpy(dst, ptr, N); // copy ptr/buf to dst
20 int main()
22 invert("abcde");
23 if (__builtin_strcmp(dst, "edcba"))
24 __builtin_abort();
25 return 0;