[Bug middle-end/85602] -Wsizeof-pointer-memaccess for strncat with size of source
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 14 20:12:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85602
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I agree that's not an improvement. Would something like this be better? (at
least until utmp_ent is marked nonstring and GCC taught to suppress the
diagnostic)
size_t utmpsize = sizeof UT_ID (utmp_ent);
char *comment = xmalloc (strlen (_("id=")) + utmpsize + 1);
strcpy (comment, _("id="));
strncat (comment, UT_ID (utmp_ent), utmpsize);
I'll try to remember to test coreutils with new warnings in the future.
More information about the Gcc-bugs
mailing list