Use common bits/shm.h for more architectures.
[glibc.git] / string / bug-strncat1.c
blobb22beba4d3d672b88ae6ae8c84b96f8de86d5454
1 /* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */
2 #undef __USE_STRING_INLINES
3 #define __USE_STRING_INLINES
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <libc-diag.h>
9 char d[3] = "\0\1\2";
11 int
12 main (void)
14 DIAG_PUSH_NEEDS_COMMENT;
15 #if __GNUC_PREREQ (8, 0)
16 /* GCC 8 warns about strncat truncating output; this is deliberately
17 tested here. */
18 DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation");
19 #endif
20 strncat (d, "\5\6", 1);
21 DIAG_POP_NEEDS_COMMENT;
22 if (d[0] != '\5')
24 puts ("d[0] != '\\5'");
25 exit (1);
27 if (d[1] != '\0')
29 puts ("d[1] != '\\0'");
30 exit (1);
32 if (d[2] != '\2')
34 puts ("d[2] != '\\2'");
35 exit (1);
38 return 0;