]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/106189 - avoid division by zero exception
authorRichard Biener <rguenther@suse.de>
Mon, 25 Jul 2022 15:24:57 +0000 (17:24 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 26 Jul 2022 06:36:53 +0000 (08:36 +0200)
commitbb04f9f23ac0dee2c003118c85372ece50a52220
treead94a3fb78bd8d22720410f2468d0344dbe77894
parent16fc26d4e7a4a7618d8d231f9b4cb7bd487fb7b8
tree-optimization/106189 - avoid division by zero exception

The diagnostic code can end up with zero sized array elements
with T[][0] and the wide-int code nicely avoids exceptions when
dividing by zero in one codepath but not in another.  The following
fixes the exception by using wide-int in both paths.

PR tree-optimization/106189
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
Divide using offset_ints.

* gcc.dg/pr106189.c: New testcase.
gcc/gimple-array-bounds.cc
gcc/testsuite/gcc.dg/pr106189.c [new file with mode: 0644]