This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/79448] unhelpful -Wformat-truncation=2 warning


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]