This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/85418] -Wformat-truncation on inlinned function
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 16 Apr 2018 19:58:02 +0000
- Subject: [Bug c/85418] -Wformat-truncation on inlinned function
- Auto-submitted: auto-generated
- References: <bug-85418-4@http.gcc.gnu.org/bugzilla/>
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);