aboutsummaryrefslogtreecommitdiff
path: root/gcc/except.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-05-22 09:13:50 +0200
committerJakub Jelinek <jakub@redhat.com>2024-05-22 09:13:50 +0200
commitdbc9b45a3c2468ad134b3a9bd4961f7ae6bc1e67 (patch)
treeb0938a3008b5ae6d1254a5938e7cf1fa3dbf0662 /gcc/except.cc
parentd3c506eff54fcbac389a529c2e98da108a410b7f (diff)
downloadgcc-dbc9b45a3c2468ad134b3a9bd4961f7ae6bc1e67.zip
gcc-dbc9b45a3c2468ad134b3a9bd4961f7ae6bc1e67.tar.gz
gcc-dbc9b45a3c2468ad134b3a9bd4961f7ae6bc1e67.tar.bz2
strlen: Fix up !si->full_string_p handling in count_nonzero_bytes_addr [PR115152]
The following testcase is miscompiled because strlen_pass::count_nonzero_bytes_addr doesn't handle correctly the !si->full_string_p case. If si->full_string_p, it correctly computes minlen and maxlen as minimum and maximum length of the '\0' terminated stgring and clears *nulterm (ie. makes sure !full_string_p in the ultimate caller) if minlen is equal or larger than nbytes and so '\0' isn't guaranteed to be among those bytes. But in the !si->full_string_p case, all we know is that there are [minlen,maxlen] non-zero bytes followed by unknown bytes, so effectively the maxlen is infinite (but caller cares about only the first nbytes bytes) and furthermore, we never know if there is any '\0' char among those, so *nulterm needs to be always cleared. 2024-05-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/115152 * tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes_addr): If !si->full_string_p, clear *nulterm and set maxlen to nbytes. * gcc.dg/pr115152.c: New test.
Diffstat (limited to 'gcc/except.cc')
0 files changed, 0 insertions, 0 deletions