This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53391] Slightly misleading warning on printf format mismatch
- From: "Keith.S.Thompson at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 May 2012 18:26:31 +0000
- Subject: [Bug c/53391] Slightly misleading warning on printf format mismatch
- Auto-submitted: auto-generated
- References: <bug-53391-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53391
--- Comment #2 from Keith Thompson <Keith.S.Thompson at gmail dot com> 2012-05-18 18:26:31 UTC ---
The cleverness I was referring to was having diagnostics refer to an
appropriate typedef rather than to the original type (e.g., "size_t" rather
than "unsigned int"). I find this clever in a *good* way.
The conversion is a no-op if my_long happens to be the same type as long, as it
is in this example -- but it's very useful from the programmer's point of view
if my_long (or something with a more meaningful name) *could* be either long or
int.
I suppose solving this would require saving some information about the cast so
that the name of the type of the expression ("my_long" rather than "long") can
be referred to in diagnostic messages.
I should note that this is not production code. The original program was
intended to use "%ld" and convert the argument to long; I ran into the
misleading warning due to a logic error.