This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81483] spurious -Wformat-overflow warning for limited types
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 19 Jul 2017 17:01:10 +0000
- Subject: [Bug middle-end/81483] spurious -Wformat-overflow warning for limited types
- Auto-submitted: auto-generated
- References: <bug-81483-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-07-19
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The VRP pass computes the correct range for the sprintf argument but the range
made available outside the pass via the get_range_info() function for the
promoted argument is that of unsigned int (a similar problem is described in
bug 78969). It's a bug/limitation in the range propagation machinery in GCC.
I'm not sure there's an easy way to work around it in the sprintf pass. If
not, hopefully the new VRP implementation will solve these problems.
Until then, a workaround is to unsigned int as the loop counter and cast it to
unsigned char in the sprintf call:
unsigned zone;
char buffer[10];
for (zone = 0; zone != num_zones; zone++)
__builtin_sprintf (buffer, "zone%02X", (unsigned char)zone);