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 tree-optimization/78913] Probably misleading error reported by -Wformat-length


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.

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