This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79448] unhelpful -Wformat-truncation=2 warning
- 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: Fri, 10 Feb 2017 00:50:05 +0000
- Subject: [Bug middle-end/79448] unhelpful -Wformat-truncation=2 warning
- Auto-submitted: auto-generated
- References: <bug-79448-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79448
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |diagnostic
Last reconfirmed| |2017-02-10
Component|c |middle-end
CC| |msebor at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=79275
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. This is similar to bug 79275. Here, the pass must assume the
output for the %s directive is the maximum possible length of a string (i.e.,
PTRDIFF_MAX - 1) and uses it as the running maximum byte counter. When it gets
to the ": " part of the format string, at level 2 it checks if the appending it
to the output produced so far will cause the maximum byte counter to exceed
INT_MAX. Since it does, it issues a warning. The checker should avoid this
test when the byte count is in a range with the lower bound less than INT_MAX
and the upper greater than (or equal to) PTRDIFF_MAX since that means a string
of unknown length.