1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
Description: Avoid ambiguous use of abs() causing build failure.
Avoid failing build with GCC 7 due to abiguous use of abs(unsigned int).
The problem is this:
unsigned int a, b, c; c = abs(a - b);
The type of a - b here is unsigned int, and abs(unsigned int) do not
exist. I solved it by changing the calculation to use signed long
instead, as abs(long) exist and should be able to handle the entire
value range.
Forwarded: no
Bug-Debian: https://bugs.debian.org/853605
Author: Petter Reinholdtsen <pere@hungry.com>
Last-Update: 2017-08-05
diff --git a/ResultTable.cc b/ResultTable.cc
index 52e5b3c..a8a2ac3 100644
--- a/ResultTable.cc
+++ b/ResultTable.cc
@@ -909,8 +909,8 @@ void ResultTable::lmsint(double &a, double &b, double &r2)
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- residuals[l] = abs(partialmins[i] -
- ((currentslope *
+ residuals[l] = abs((long)partialmins[i] -
+ (long)((currentslope *
column2size(i) /
slopescale) +
currentintercept));
@@ -930,7 +930,7 @@ void ResultTable::lmsint(double &a, double &b, double &r2)
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- ys[l] = abs(partialmins[i] - mediany);
+ ys[l] = abs((long)partialmins[i] - (long)mediany);
l++;
}
}
|