[Bug tree-optimization/84480] Unexpected -Wstringop-truncation on strncpy with string literal at -O2

romain.geissler at amadeus dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 21 11:29:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84480

--- Comment #1 from Romain Geissler <romain.geissler at amadeus dot com> ---
Hi,

I looked at the code. Actually all happens in tree-ssa-strlen.c, you have both
handle_builtin_stxncpy and maybe_diag_stxncpy_trunc. It happens that the logic
where you look at the next statement to check if its like "array[arraySize -1]
= '\0' is only implemented in maybe_diag_stxncpy_trunc. Somehow the very same
logic should be implemented in handle_builtin_stxncpy around line 2103 where
you throw this warning.

Cheers,
Romain


More information about the Gcc-bugs mailing list