This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/78913] Probably misleading error reported by -Wformat-length
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 02 Jan 2017 08:15:28 +0000
- Subject: [Bug tree-optimization/78913] Probably misleading error reported by -Wformat-length
- Auto-submitted: auto-generated
- References: <bug-78913-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78913
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #5)
> (In reply to Martin Sebor from comment #4)
> > 1) use the %.508s directive instead of %s, or
> > 2) verify the snprintf return value is less than 512.
>
> Whoops. An off-by-one error. I meant to follow that by:
>
> > Of the two alternatives, (1) is the expected/recommended way to avoid both
> > the truncation and the warning. (2) is a possible enhancement that could
> > also be used to suppress the warning (along with changing the code).
Thanks Martin for very verbose explanation. To be honest, I'm not much
interested in this particular test-case as it comes from a random package in
openSUSE that started to fail with new GCC version. I would incline to let this
PR opened as a reminder that cooperation of string manipulation functions is
needed to provide more precise warnings.
I will probably choose to fix my concrete package with %.xs format.