Use the determined lower bound of the range of offsets in a PLUS_EXPR.
authorMartin Sebor <msebor@redhat.com>
Tue, 1 Sep 2020 22:02:19 +0000 (16:02 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 1 Sep 2020 22:03:25 +0000 (16:03 -0600)
commit0c344a649d803a83ed35f629d292b98143935ffa
tree069c12b4eb9f1263b68f13d0a2027908cb58204f
parentb1c59b31ef7adc832405209e9e2a77212284abd7
Use the determined lower bound of the range of offsets in a PLUS_EXPR.

gcc/ChangeLog:

* builtins.c (compute_objsize):  Only replace the upper bound
of a POINTER_PLUS offset when it's less than the lower bound.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overflow.c: Remove xfails.
* gcc.dg/Wstringop-overflow-42.c: New test.
* gcc.dg/Wstringop-overread-4.c: New test.
gcc/builtins.c
gcc/testsuite/gcc.dg/Wstringop-overflow-42.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wstringop-overflow.c
gcc/testsuite/gcc.dg/Wstringop-overread-4.c [new file with mode: 0644]