summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-10-26 15:33:40 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-10-26 15:33:40 +0200
commitade8521657d5d52cd5d67a60859f34c1b32c8e34 (patch)
tree5e4dc9dc7a16d9ff3ca19ba6273089d9595da0ba
parentd556c282aaa59476e67e69d39f116e132ec189df (diff)
Fix o3tl::saturating_add for negative b
Change-Id: I665f6c2f94b6c03d6fb5136fff3054ad6f0ca962
-rw-r--r--include/o3tl/safeint.hxx4
1 files 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<std::is_signed<T>::value, T>::type saturating_add(
return std::numeric_limits<T>::max();
}
} else {
- if (a >= std::numeric_limits<T>::min() + b) {
- return a - b;
+ if (a >= std::numeric_limits<T>::min() - b) {
+ return a + b;
} else {
return std::numeric_limits<T>::min();
}