[cfe-commits] [Patch] Teach format string analysis that "%zu" means size_t.

Hans Wennborg hans at chromium.org
Wed Oct 26 09:07:11 PDT 2011


Hi all,

The attached patch teaches format string analysis that "%zu" means size_t.

The code had it backwards, thinking size_t was signed, and using that for "%zd".

Also let the analysis get the types for (u)intmax_t while we are at it.

Please take a look and let me know if this is ok to land.

Any ideas for the remaining FIXMEs in PrintfFormatString.cpp, i.e. how
to get a hold of a type that's the same width as size_t, but signed
would be appreciated. (And the same for unsigned version of ptrdiff_t,
though I suppose that is less common.)

It would also be cool if the warning could say "conversion specifies
type 'size_t' (a.k.a. 'unsigned long')", rather than just using the
underlying type, but that's probably for another patch.

Thanks,
Hans



More information about the cfe-commits mailing list