[Bug tree-optimization/87034] [9 Regression] missing -Wformat-overflow on a sprintf %s with a wide string

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Dec 22 01:01:00 GMT 2018


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

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning in GCC 8 isn't bogus, it just reports the wrong number of bytes (it
counts characters, not bytes).  That the warning is no longer issued is a
regression caused by c_strlen() giving up when the size of the constant array
element doesn't match the expected size (in this case, sizeof(wchat_t) vs
sizeof(char)).  That change was made out of an abundance of caution in an
effort to avoid folding suspect expressions that were felt didn't need to be
folded (e.g., strlen((char*)L"\x41424344\x45464748")).  There's nothing
inherently wrong with folding those expressions, but they don't need to be
folded for GCC to understand their length and make use of it to issue warnings.


More information about the Gcc-bugs mailing list