[Bug sanitizer/84732] false-positive -Wstringop-truncation warning with -fsanitize-coverage=trace-pc
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 7 13:41:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84732
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Short testcase for the latter, -O2 -Wall vs. -O2 -Wall -fsanitize=address:
struct S { char p[32]; };
struct S *
foo (char *q)
{
struct S *p = __builtin_malloc (sizeof (struct S));
__builtin_strncpy (p->p, q, 32);
p->p[31] = '\0';
return p;
}
With -fsanitize={,kernel-}address there is:
__builtin_strncpy (_1, q_5(D), 32);
_8 = &p_4->p[31];
ASAN_CHECK (7, _8, 1, 1);
p_4->p[31] = 0;
So, the -Wstringop-truncation would need to do the suggested alias search for
the store rather than next statement it does now, and in addition to that would
need to ignore ASAN_CHECK, because those are guaranteed not to actually read
the passed memory, just to check corresponding shadow memory.
More information about the Gcc-bugs
mailing list