[Bug c++/83429] Incorrect line number reported by -Wformat-truncation

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 15 17:37:00 GMT 2017


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-12-15
                 CC|                            |msebor at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=83369,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=83336
     Ever confirmed|0                           |1

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  The whole sprintf pass is missing the %G directive in warning_at()
calls to print the inlining context.  With it added the warning for the test
case from comment #2 looks like this:

d.c: In function ‘void test(S*)’:
d.c:16:17: warning: ‘%s’ directive argument is null [-Wformat-truncation=]
         snprintf(s->out, sizeof(s->out), ".%s", s->str);
         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This should be easy to fix.  It's been in the back of my mind to do this but it
hasn't risen up to the top of the priority list.  With a bug reported for it I
have more of an incentive -- thanks :)

For reference, pr83369 and pr83336 point out similar or related problems with
the inlining context.


More information about the Gcc-bugs mailing list