On 02/04/2017 10:37 AM, Martin Sebor wrote:
There's a "thinko" in the get_range_strlen() function that computes
the range of possible string lengths for a character pointer that
may point to an array holding a string of unknown length and a string
literal. The bug lets the function return the length of the string
as the lower bound (and the size of the array -1 as the upper bound),
which isn't correct. The lower bound in this case must be zero because
the array could be the empty string.
The attached patch corrects this error.
Martin
gcc-79376.diff
gcc/ChangeLog:
* gimple-fold.c (get_range_strlen): Set the minimum length to zero.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/builtin-sprintf-warn-14.c: New test.
* gcc.dg/tree-ssa/pr79376.c: New test.
OK.
jeff