diff options
author | Martin Sebor <msebor@redhat.com> | 2019-08-27 23:31:44 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-08-27 17:31:44 -0600 |
commit | 407b92bcfb34f352b6aad7b629bf365c02114469 (patch) | |
tree | aae733d110df9ec932c4b6e87ca9b79a1ae4305b /gcc/vr-values.c | |
parent | 2d8ba44101028f4be534a20a0d2146695e1dc4fd (diff) | |
download | gcc-407b92bcfb34f352b6aad7b629bf365c02114469.zip gcc-407b92bcfb34f352b6aad7b629bf365c02114469.tar.gz gcc-407b92bcfb34f352b6aad7b629bf365c02114469.tar.bz2 |
PR tree-optimization/91567 - Spurious -Wformat-overflow warnings building glibc (32-bit only)
gcc/ChangeLog:
PR tree-optimization/91567
* gimple-ssa-sprintf.c (get_string_length): Handle more forms of lengths
of unknown strings.
* vr-values.c (vr_values::extract_range_basic): Set strlen upper bound
to PTRDIFF_MAX - 2.
gcc/testsuite/ChangeLog:
PR tree-optimization/91567
* gcc.dg/tree-ssa/builtin-snprintf-6.c: Xfail a subset of assertions
on targets other than x86_64 to work around PR 83543.
* gcc.dg/tree-ssa/builtin-sprintf-warn-22.c: New test.
From-SVN: r274976
Diffstat (limited to 'gcc/vr-values.c')
-rw-r--r-- | gcc/vr-values.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 96c764c..256cae7 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -1319,7 +1319,12 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt) tree max = vrp_val_max (ptrdiff_type_node); wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max))); tree range_min = build_zero_cst (type); - tree range_max = wide_int_to_tree (type, wmax - 1); + /* To account for the terminating NUL, the maximum length + is one less than the maximum array size, which in turn + is one less than PTRDIFF_MAX (or SIZE_MAX where it's + smaller than the former type). + FIXME: Use max_object_size() - 1 here. */ + tree range_max = wide_int_to_tree (type, wmax - 2); vr->set (VR_RANGE, range_min, range_max); return; } |