https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105597
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Andrew Macleod <amacl...@gcc.gnu.org>: https://gcc.gnu.org/g:e97e99296505e6015bc9e281364818bb89ca8a49 commit r13-449-ge97e99296505e6015bc9e281364818bb89ca8a49 Author: Andrew MacLeod <amacl...@redhat.com> Date: Fri May 13 13:11:18 2022 -0400 Check operand for type, not LHS. When folding, the LHS has not been set, so we should be checking the type of op1. We should also make sure op1 is not undefined. PR tree-optimization/105597 gcc/ * range-op.cc (operator_minus::lhs_op1_relation): Use op1 instead of the lhs and make sure it is not undefined. gcc/testsuite/ * gcc.dg/pr105597.c: New.