mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-08 14:20:07 +00:00
ec72135e5f
GCC 8 warns about strncat calls with truncated output. string/bug-strncat1.c tests such a call; this patch disables the warning for it. Tested (compilation) with GCC 8 for x86_64-linux-gnu with build-many-glibcs.py (in conjunction with Martin's patch to allow glibc to build). * string/bug-strncat1.c: Include <libc-diag.h>. (main): Disable -Wstringop-truncation for strncat call for GCC 8.
40 lines
747 B
C
40 lines
747 B
C
/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */
|
|
#undef __USE_STRING_INLINES
|
|
#define __USE_STRING_INLINES
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <libc-diag.h>
|
|
|
|
char d[3] = "\0\1\2";
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
DIAG_PUSH_NEEDS_COMMENT;
|
|
#if __GNUC_PREREQ (8, 0)
|
|
/* GCC 8 warns about strncat truncating output; this is deliberately
|
|
tested here. */
|
|
DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation");
|
|
#endif
|
|
strncat (d, "\5\6", 1);
|
|
DIAG_POP_NEEDS_COMMENT;
|
|
if (d[0] != '\5')
|
|
{
|
|
puts ("d[0] != '\\5'");
|
|
exit (1);
|
|
}
|
|
if (d[1] != '\0')
|
|
{
|
|
puts ("d[1] != '\\0'");
|
|
exit (1);
|
|
}
|
|
if (d[2] != '\2')
|
|
{
|
|
puts ("d[2] != '\\2'");
|
|
exit (1);
|
|
}
|
|
|
|
return 0;
|
|
}
|