]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-ssa-dce: Fix calloc handling [PR118224]
authorJakub Jelinek <jakub@redhat.com>
Mon, 20 Jan 2025 09:24:18 +0000 (10:24 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 20 Jan 2025 09:24:18 +0000 (10:24 +0100)
commitd882e48d48bf300941c3610c5af157c64ccf0a84
tree2d5df2fad6edd550a2e9acd37bd99857fe7d1cbc
parent459816efa13d9d553a5c900336f6eef22072f1a1
tree-ssa-dce: Fix calloc handling [PR118224]

As reported by Dimitar, this should have been a multiplication, but wasn't
caught because in the test (~(__SIZE_TYPE__) 0) / 2 is the largest accepted
size and so adding 3 to it also resulted in "overflow".

The following patch adds one subtest to really verify it is a multiplication
and fixes the operation.

2025-01-20  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118224
* tree-ssa-dce.cc (is_removable_allocation_p): Multiply a1 by a2
instead of adding it.

* gcc.dg/pr118224.c: New test.
gcc/testsuite/gcc.dg/pr118224.c
gcc/tree-ssa-dce.cc