From 651d2fd7519eed8aeebcd14518045621cac14a29 Mon Sep 17 00:00:00 2001 From: Frederic Bonnard Date: Fri, 8 Dec 2017 15:42:50 +0100 Subject: [PATCH] Fix "Unit overflow in pow()" error During tests on Debian/Ubuntu : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=836983 a problem was found when raising a unit to a negative power on some architectures. By default some architectures have "char" being unsigned such as the ones listed here and others ( https://wiki.debian.org/ArchitectureSpecificsMemo ). I just forced the sign-ness of pow()'s argument which fixes the issue. --- src/Base/Unit.cpp | 2 +- src/Base/Unit.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp index 569a40ebbc..e63b321eb9 100644 --- a/src/Base/Unit.cpp +++ b/src/Base/Unit.cpp @@ -127,7 +127,7 @@ Unit::Unit(const QString& expr) } } -Unit Unit::pow(char exp) const +Unit Unit::pow(signed char exp) const { checkRange("pow()", (int32_t)Sig.Length * (int32_t)exp, diff --git a/src/Base/Unit.h b/src/Base/Unit.h index 7b0b335c0c..115d14eeab 100644 --- a/src/Base/Unit.h +++ b/src/Base/Unit.h @@ -79,7 +79,7 @@ public: bool operator ==(const Unit&) const; bool operator !=(const Unit&that) const {return !(*this == that);} Unit& operator =(const Unit&); - Unit pow(char exp)const; + Unit pow(signed char exp)const; //@} /// get the unit signature const UnitSignature & getSignature(void)const {return Sig;}