public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65446] Improve -Wformat-signedness
[not found] <bug-65446-4@http.gcc.gnu.org/bugzilla/>
@ 2015-03-17 8:53 ` burnus at gcc dot gnu.org
2015-05-21 16:11 ` eblake at redhat dot com
2015-05-21 17:26 ` eblake at redhat dot com
2 siblings, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2015-03-17 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65446
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #0)
> It doesn't warn but should warn for
> printf("%u\n", _short);
Actually, it (correctly) does warn in this case (as short it promoted to int,
which is also unsigned).
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/65446] Improve -Wformat-signedness
[not found] <bug-65446-4@http.gcc.gnu.org/bugzilla/>
2015-03-17 8:53 ` [Bug c/65446] Improve -Wformat-signedness burnus at gcc dot gnu.org
@ 2015-05-21 16:11 ` eblake at redhat dot com
2015-05-21 17:26 ` eblake at redhat dot com
2 siblings, 0 replies; 3+ messages in thread
From: eblake at redhat dot com @ 2015-05-21 16:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65446
Eric Blake <eblake at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |eblake at redhat dot com
--- Comment #2 from Eric Blake <eblake at redhat dot com> ---
'unsigned short' promotes to 'int', not 'unsigned int', when passed through
var-args. The warning is technically correct, but annoying, since all values
of 'unsigned short' are representable in both 'int' and in 'unsigned int',
therefore %d vs. %u won't ever have to deal with a negative value.
"%u" with signed 'short' should indeed warn, because that is a case where
promotion to 'int' differs from printing unsigned values.
"%x" with 1 should indeed warn, because that is passing 'int'. Use "%x" with
1U if you want to avoid the warning.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/65446] Improve -Wformat-signedness
[not found] <bug-65446-4@http.gcc.gnu.org/bugzilla/>
2015-03-17 8:53 ` [Bug c/65446] Improve -Wformat-signedness burnus at gcc dot gnu.org
2015-05-21 16:11 ` eblake at redhat dot com
@ 2015-05-21 17:26 ` eblake at redhat dot com
2 siblings, 0 replies; 3+ messages in thread
From: eblake at redhat dot com @ 2015-05-21 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65446
--- Comment #4 from Eric Blake <eblake at redhat dot com> ---
Arguably, "%u" with short should warn, while "%hu" with short should not. On
the other hand, if I use "%hu" with int, it is unclear to me whether I should
get a warning (the fact that I'm using %h to intentionally truncate the value
before it is printed, even though %hu and %hd print different values, makes it
hard to discern whether I have a mismatch). But this does mean that whatever
changes are made to -Wformat-signedness, it should take into account the use of
%h range-limiting vs. pre-integer-promotion types.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-21 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-65446-4@http.gcc.gnu.org/bugzilla/>
2015-03-17 8:53 ` [Bug c/65446] Improve -Wformat-signedness burnus at gcc dot gnu.org
2015-05-21 16:11 ` eblake at redhat dot com
2015-05-21 17:26 ` eblake at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).