[Bug middle-end/77708] -Wformat-length %s warns for snprintf

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 23 16:37:00 GMT 2016


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-09-23
                 CC|                            |msebor at gcc dot gnu.org
          Component|c                           |middle-end
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is by design here but I will confirm the report as a request for
change.

I agree that, especially when the snprintf return value is used, warning at the
default level may not be helpful.  I'm not sure if a warning should be issued
at a higher level, not at all, or under a separate option.  I'd like to get the
input from others before making a change.

I'm not sure that suppressing the warning at level 1 when the snprintf return
value isn't used is a good idea.  Such calls typically assume that the output 
will not be truncated and subsequent code isn't prepared to handle it.  I fixed
a few such cases in GCC when testing the warning.


More information about the Gcc-bugs mailing list