Using GCC 8.2.0 I see the following error. /usr/bin/gcc-8 -Wall -Werror -Wuninitialized -Wundef -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -g -O2 -Wp,-MMD,./.lsmmc.o.d,-MT,lsmmc.o -c lsmmc.c -o lsmmc.o In file included from /usr/include/string.h:494, from lsmmc.c:46: In function ‘strncpy’, inlined from ‘read_file’ at lsmmc.c:356:3: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ accessing 4096 bytes at offsets 0 and 1 overlaps 4095 bytes at offset 1 [-Werror=restrict] return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Makefile:36: recipe for target 'lsmmc.o' failed make: *** [lsmmc.o] Error 1 Hence replace the strncpy with memmove, since using strncpy on overlapping strings is not allowed. Signed-off-by: Hans-Christian Noren Egtvedt <egtvedt@xxxxxxxxxxxx> --- lsmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsmmc.c b/lsmmc.c index c4faa00..7637198 100644 --- a/lsmmc.c +++ b/lsmmc.c @@ -353,7 +353,7 @@ char *read_file(char *name) line[strlen(line) - 1] = '\0'; while (isspace(line[0])) - strncpy(&line[0], &line[1], sizeof(line)); + memmove(&line[0], &line[1], sizeof(line) - 1); return strdup(line); } -- 2.17.1