diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-03-14 15:30:43 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-03-14 15:30:43 +0100 |
commit | 7f476ee30bab3976eefc3226481e617add83401a (patch) | |
tree | 0390818a16442b72a8e24ba1d0a64a75a193c9eb /gcc/rust/util | |
parent | 5abe571e0276fafcc6eed27c27abb28943e67c6f (diff) | |
download | gcc-7f476ee30bab3976eefc3226481e617add83401a.zip gcc-7f476ee30bab3976eefc3226481e617add83401a.tar.gz gcc-7f476ee30bab3976eefc3226481e617add83401a.tar.bz2 |
analyzer: Fix ICE in cmp_csts_same_type on RAW_DATA_CST [PR119278]
The following testcase ICEs in cmp_csts_same_type because RAW_DATA_CST
isn't handled there. As TREE_TYPE (cst1) in that case is INTEGER_TYPE,
e.g. char/signed char/unsigned char, the type itself doesn't imply
the size, so the length is compared first, followed by comparing the
data.
While at it, I've noticed STRING_CST handling is wrong, because STRING_CST
can represent even string literals with embedded nul characters.
We shouldn't stop at those, hence memcmp.
While for STRING_CST TREE_TYPE should likely already imply the length
and so same type should imply same TREE_STRING_LENGTH, I've repeated
the comparisons in there just in case.
2025-03-14 Jakub Jelinek <jakub@redhat.com>
PR analyzer/119278
* svalue.cc (cmp_csts_same_type): For STRING_CST, compare
TREE_STRING_LENGTH first just in case and use memcmp rather
than strcmp. Handle RAW_DATA_CST.
* c-c++-common/analyzer/pr119278.c: New test.
Diffstat (limited to 'gcc/rust/util')
0 files changed, 0 insertions, 0 deletions