From ade8521657d5d52cd5d67a60859f34c1b32c8e34 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 26 Oct 2017 15:33:40 +0200 Subject: Fix o3tl::saturating_add for negative b Change-Id: I665f6c2f94b6c03d6fb5136fff3054ad6f0ca962 --- include/o3tl/safeint.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/o3tl/safeint.hxx b/include/o3tl/safeint.hxx index 8b735fe2edfa..47baccf067f8 100644 --- a/include/o3tl/safeint.hxx +++ b/include/o3tl/safeint.hxx @@ -37,8 +37,8 @@ typename std::enable_if::value, T>::type saturating_add( return std::numeric_limits::max(); } } else { - if (a >= std::numeric_limits::min() + b) { - return a - b; + if (a >= std::numeric_limits::min() - b) { + return a + b; } else { return std::numeric_limits::min(); } -- cgit