On 01/30/2017 02:28 PM, Martin Sebor wrote:
Bug 79275 - -Wformat-overflow false positive exceeding INT_MAX in
glibc sysdeps/posix/tempname.c points out a false positive found
during a Glibc build and caused by the checker using the upper
bound of a range of precisions in string directives with string
arguments of non-constant length.  The attached patch relaxes
the checker to use the lower bound instead when appropriate.

Martin

gcc-79275.diff


PR middle-end/79275 -  -Wformat-overflow false positive exceeding INT_MAX in 
glibc sysdeps/posix/tempname.c

gcc/testsuite/ChangeLog:

        PR middle-end/79275
        * gcc.dg/tree-ssa/builtin-sprintf-warn-11.c: New test.
        * gcc.dg/tree-ssa/pr79275.c: New test.

gcc/ChangeLog:

        PR middle-end/79275
        * gimple-ssa-sprintf.c (get_string_length): Set lower bound to zero.
        (format_string): Tighten up the range of output for non-constant
        strings and correct the expected range for wide non-constant strings.
Couple more nits.

First, I expect the patch won't apply as-is with the operand order fixes. There'll be trivial changes you'll need to make for that.

Along the same lines, this patch would introduce a new operand order nit here:


+       }
+      else if (0 <= dir.prec[1])
+       {

Please consider documenting how we handle strings with unknown lengths.


I don't think those warrant waiting for another review round. Fix, bootstrap, test and install.

jeff

Reply via email to