1 /* { dg-do run } */
2
3 #define N 23
4 #define MAX_LEN 13
5 char dst[N + 1];
6
7 void __attribute__((noipa))
8 invert(const char *id)
9 {
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
15 }
16 __builtin_strncpy(dst, ptr, N); // copy ptr/buf to dst
17 }
18
19
20 int main()
21 {
22 invert("abcde");
23 if (__builtin_strcmp(dst, "edcba"))
24 __builtin_abort();
25 return 0;
26 }