public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "scovich at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/32291] New: -Wformat either too picky or not picky enough Date: Mon, 11 Jun 2007 20:29:00 -0000 [thread overview] Message-ID: <bug-32291-14600@http.gcc.gnu.org/bugzilla/> (raw) Compiling the following snippet with -Wformat (or -Wall) causes the compiler to complain: "wformat-bug.C:8: warning: format '%u' expects type 'unsigned int', but argument 2 has type 'uint32_t'" The problem seems to be that stdint.h defines uint32_t as "long" in cygwin. I realize that int != long on some platforms, but i686 isn't one of them. Why should the user be forced to cast their uint32_t (read: 32-bit unsigned int) to "unsigned int" before passing it to printf() when they are logically identical? On the other hand, there's no complaint about passing a signed integer into an unsigned format or vice-versa, even though the output value might actually change because of the oversight in those cases. wformat.C: ======================================= #include <cstdio> #include <stdint.h> int main() { uint32_t a = ~0; unsigned int b = a; uint32_t c = b; printf("%u\n", c); // warning (?) int d = c; unsigned e = d; printf("%d\n", e); // no warning printf("%u\n", d); // no warning } -- Summary: -Wformat either too picky or not picky enough Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: scovich at gmail dot com GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32291
next reply other threads:[~2007-06-11 20:29 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-06-11 20:29 scovich at gmail dot com [this message] 2007-06-11 20:50 ` [Bug c++/32291] " schwab at suse dot de 2010-02-21 0:15 ` manu at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-32291-14600@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).