From c6dbd14ec8ff94df47d3c2137cc5234203ec5e0c Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 08:43:17 +0000 Subject: fix: check division and modulo for zero divisors Co-Authored-By: Claude Fable 5.1 --- lib/CodeGen/RuntimeCheck.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/RuntimeCheck.cc') diff --git a/lib/CodeGen/RuntimeCheck.cc b/lib/CodeGen/RuntimeCheck.cc index 40304fd..8075873 100644 --- a/lib/CodeGen/RuntimeCheck.cc +++ b/lib/CodeGen/RuntimeCheck.cc @@ -57,7 +57,12 @@ void RuntimeCheck::emitErrorAndExit(Value *Condition, Value *Msg, ArrayRefgetType()->isDoubleTy()) { + IsZero = Builder.CreateFCmpOEQ(Divisor, ConstantFP::get(Divisor->getType(), 0.0), "is_zero"); + } else { + IsZero = Builder.CreateICmpEQ(Divisor, ConstantInt::get(Divisor->getType(), 0), "is_zero"); + } emitErrorAndExit(IsZero, DivZeroMsg, Line); } -- cgit v1.3.1-4-g156e