[Bug c/77970] inconsistent and unhelpful -Wformat warning for %lc
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 13 17:31:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77970
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
I think the correct logic would be something like: if the argument is for
a standard typedef, and the format doesn't correspond exactly to that
typedef (or one differing only by sign, e.g. allow %ju for an intmax_t
unless -Wformat-signedness), warn (with an option to disable it) even if
they match (or match up to sign) on this particular system. Likewise if
the format is for a standard typedef but the argument isn't. Hard to
implement for various reasons (including <inttypes.h> format macros -
glibc's definitions of those for intmax_t match the underlying type rather
than using "j", for example), and would have false positives in various
cases, but more warnings rather than less seems right here and would make
warnings more consistent between targets.
The option to disable warnings for mismatched typedefs could then have
different stringencies for whether it disables even int/long mismatches,
or only cases that already wouldn't warn but for the use of standard
typedefs.
More information about the Gcc-bugs
mailing list