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 c/85418] -Wformat-truncation on inlinned function


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is intended (and designed to trigger across inlined function
calls).  The call to snprintf() truncates the string which may be unintended.

To avoid the warning either use the return value of the snprintf function to
take some action (i.e., handle the truncation) or use the len argument to
specify the precision of the %s directive like so:

    snprintf (b, sizeof b, "%.*s", (int)len, s);

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