https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83404
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=83412 --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- It should and does as long as the result is used (see below) and as long as some GCC bug doesn't get in the way. When <string.h> defines strncat as macro like in Glibc 2.24 the warning doesn't trigger. I opened bug 83412 for it. There's also bug 82944 that I thought was due to warnings being suppressed for macros defined in system headers but maybe it's actually the same as bug 83412. Phew. $ cat a.c && gcc -O2 -S -Wall a.c extern char* strncpy (char*, const char*, __SIZE_TYPE__); extern char* strncat (char*, const char*, __SIZE_TYPE__); int main (void) { char x[12]; strncpy (x, "", 12); strncat (x, "aa", 1); __builtin_puts (x); } a.c: In function ‘main’: a.c:10:3: warning: ‘strncat’ output truncated copying 1 byte from a string of length 2 [-Wstringop-truncation] strncat (x, "aa", 1); ^~~~~~~~~~~~~~~~~~~~