I have an array of doubles and need to do a calculation on that array and then find the min and max value that results from that calculation. Here is basically what I have:
double * array;
double result;
double myMin;
double myMax;
// Assume array is initialized properly...
for (int i = 0; i < sizeOfArray; ++i) {
result = transmogrify(array[i]);
if (i == 0) {
myMin = result;
myMax = result;
}
else if (result < myMin) {
myMin = result;
}
else if (result > myMax) {
myMax = result;
}
}
I'm getting a warning that the value computed for result
is never used, and since we treat all warnings as errors, this doesn't compile. How can I fix this code to avoid the warning? I'm using g++ for my compiler.
Here's the warning text:
cc1plus: warnings being treated as errors
foo.cc:<lineno of transmogrify call>: error: value computed is not used
Edit: I don't understand the down votes, but I've got things working now. Thanks to everyone for taking the time to help me out.