1 | #undef __USE_STRING_INLINES |
2 | #define __USE_STRING_INLINES |
3 | #include <stdio.h> |
4 | #include <stdlib.h> |
5 | #include <string.h> |
6 | #include <libc-diag.h> |
7 | |
8 | char d[3] = "\0\1\2" ; |
9 | |
10 | int |
11 | main (void) |
12 | { |
13 | DIAG_PUSH_NEEDS_COMMENT; |
14 | #if __GNUC_PREREQ (8, 0) |
15 | /* GCC 8 warns about strncat truncating output; this is deliberately |
16 | tested here. */ |
17 | DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation" ); |
18 | #endif |
19 | strncat (dest: d, src: "\5\6" , n: 1); |
20 | DIAG_POP_NEEDS_COMMENT; |
21 | if (d[0] != '\5') |
22 | { |
23 | puts (s: "d[0] != '\\5'" ); |
24 | exit (1); |
25 | } |
26 | if (d[1] != '\0') |
27 | { |
28 | puts (s: "d[1] != '\\0'" ); |
29 | exit (1); |
30 | } |
31 | if (d[2] != '\2') |
32 | { |
33 | puts (s: "d[2] != '\\2'" ); |
34 | exit (1); |
35 | } |
36 | |
37 | return 0; |
38 | } |
39 | |