public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jay dot krell at cornell dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/44984] New: gcc passes unsigned instead of int for printf width/precision (warnings generated) Date: Mon, 19 Jul 2010 07:25:00 -0000 [thread overview] Message-ID: <bug-44984-16543@http.gcc.gnu.org/bugzilla/> (raw) 4.3.5 but 4.5.0 looks about the same, but it has an additional instance: mber/dpd -I../libdecnumber -I/usr/local/include ../../gcc/gcc/opts.c -o opts.o ../../gcc/gcc/opts.c: In function `wrap_help': ../../gcc/gcc/opts.c:1037: warning: field width is not type int (arg 3) ../../gcc/gcc/opts.c:1037: warning: field width is not type int (arg 5) ../../gcc/gcc/opts.c: In function `common_handle_option': ../../gcc/gcc/opts.c:1409: warning: field width is not type int (arg 3) gcc -c -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissin jbook2:gcc jay$ diff -uw opts.c.orig opts.c --- opts.c.orig 2010-07-19 00:07:18.000000000 -0700 +++ opts.c 2010-07-19 00:16:27.000000000 -0700 @@ -1034,7 +1034,10 @@ } } - printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help); + gcc_assert(col_width <= INT_MAX); + gcc_assert(item_width <= INT_MAX); + gcc_assert(len <= INT_MAX); + printf (" %-*.*s %.*s\n", (int)col_width, (int)item_width, item, (int)len, help); item_width = 0; while (help[len] == ' ') len++; @@ -1404,9 +1407,12 @@ } if (i == cl_lang_count) + { + gcc_assert (len <= INT_MAX); fnotice (stderr, "warning: unrecognized argument to --help= switch: %.*s\n", - len, a); + (int)len, a); + } } if (comma == NULL) This makes a line go a little over 80 columns, but one of the "nearby" lines does already. (nearby as presented here, not really in the code) This probably isn't the best fix. if the output is "not important", and someone manages to create huge data, should still work. Yes, I'm aware of that "huge" is 2GB. Maybe: int to_reasonable_diagnostic_length(unsigned i) { return (i <= INT_MAX) ? i : 255; } or int unint_to_int_pin(unsigned i) { return (i <= INT_MAX) ? i : INT_MAX; } and then apply those. - Jay -- Summary: gcc passes unsigned instead of int for printf width/precision (warnings generated) Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jay dot krell at cornell dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44984
next reply other threads:[~2010-07-19 7:25 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-07-19 7:25 jay dot krell at cornell dot edu [this message] 2010-07-20 22:51 ` [Bug middle-end/44984] " pinskia at gcc dot gnu dot org 2010-07-20 22:53 ` pinskia 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-44984-16543@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).