From 939ec878a00803502f2e07347c09fa6736c5f44a Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 6 May 2019 21:41:08 +0200 Subject: [PATCH] Fix edge case in addXf3 The operands may be zero, use the wrapping operators and avoid a spurious integer-overflow error. --- std/special/compiler_rt/addXf3.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/special/compiler_rt/addXf3.zig b/std/special/compiler_rt/addXf3.zig index 3a70461eca..5852f3e50d 100644 --- a/std/special/compiler_rt/addXf3.zig +++ b/std/special/compiler_rt/addXf3.zig @@ -78,8 +78,8 @@ fn addXf3(comptime T: type, a: T, b: T) T { const infRep = @bitCast(Z, std.math.inf(T)); // Detect if a or b is zero, infinity, or NaN. - if (aAbs - Z(1) >= infRep - Z(1) or - bAbs - Z(1) >= infRep - Z(1)) + if (aAbs -% Z(1) >= infRep - Z(1) or + bAbs -% Z(1) >= infRep - Z(1)) { // NaN + anything = qNaN if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit);