[Bug c/83011] -Wformat-truncation wrongly computes length (depends on the position of numbers in the addition)

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 16 00:09:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83011

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2017-11-16
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I cannot reproduce any warnings with the INN function (extracted from timer.c),
either with the top of trunk (GCC 8) or with the top of GCC 7-branch.  Can you
provide a preprocessed translation unit (the result of compiling timer.c with
-E instead of -c), and the compiler options?

I think in English the note would read like:

  snprintf output 2 or more bytes (assuming 3) into a destination of size 1

This is issued when the output is in some range where the lower bound would fit
but the upper bound would not.  Since the string is an argument and the buffer
size depends on timer_count which also unknown it's not clear to me what the
range is being determined from.  Are you using -flto to build the project?


More information about the Gcc-bugs mailing list