This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/77690] -Wformat-length %s false positive after strlen check
- 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: Fri, 23 Sep 2016 03:02:03 +0000
- Subject: [Bug c/77690] -Wformat-length %s false positive after strlen check
- Auto-submitted: auto-generated
- References: <bug-77690-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77690
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2016-09-23
CC| |msebor at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |7.0
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Unfortunately, even though it seems like the if statement with the strlen call
should help, the length range information isn't available to the warning pass.
The warning can, however, be avoided by constraining the length of the string
argument output by specifying the precision in the directive like so:
sprintf(foo, "zz%.4s", s.buf);
Please let me know if this isn't sufficient to resolve the problem report.