https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77743
Bug ID: 77743
Summary: bogus -Wformat-length sprintf warnings
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: amodra at gmail dot com
Target Milestone: ---
Found during build of current binutils.
bfd/ihex.c:222:19: error: '%03o' directive writing between 3 and 11 bytes into
a region of size 9 [-Werror=format-length=]
sprintf (buf, "\\%03o", (unsigned int) c & 0xff);
Should not assume full range of unsigned int.
bfd/coff-rs6000.c:3453:4: note: format output between 5 and 11 bytes into a
destination of size 10
sprintf (reloc_type_name, "0x%02x", rel->r_type);
r_type is an unsigned short. Again seems to assume full range of unsigned int.
bfd/coff-rs6000.c:1659:23: error: '%ld' directive writing between 1 and 20
bytes into a region of size 12 [-Werror=format-length=]
sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
Another case where range info says the %ld value is at most 11 bytes.