This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] - improve sprintf buffer overflow detection (middle-end/49905)
On Wed, 5 Oct 2016, Martin Sebor wrote:
> The warning would only helpful if there was a target where wchar_t
> didn't promote to a type with the same precision as wint_t, or in
Or it could show up a logical error where the code should have had a
wint_t variable and checked for WEOF somewhere but just assumed things
would fit in wchar_t (and so could be passing a negative value where the
ABI means the callee expects wint_t values to be zero-extended, with
consequent undefined behavior there). The correct fix involves thinking
about where you know something is a wide character, and where something
might be a wide character or WEOF. It might then involve a cast to
wint_t, or changing the type of a variable, or more changes than that.
--
Joseph S. Myers
joseph@codesourcery.com