Edited for test case and compiler inconsistency. Recently I made a change to use the more modern < cmath > instead of < math.h >. While this compiled just fine as expected with no warnings, this one-line change for one file caused my test cases to fail. From my understanding, cmath just puts most of the functions/variables in the std namespace, and I don't make any changes to that namespace.
I'll note I am using
sqrt
abs (since I am using doubles here I would assume the compiler would automatically use the cmath/math.h form, not stdlib)
tan
out of any files potentially affected by this one-line change on one file. I do have a different file that is already using cmath, but does not affect the testing.
A test case with
#include <iostream>
#include <cmath>
int main() {
double x = -0.546;
double y = abs( x / sqrt(x*x + 1.0));
double z = std::abs( x / sqrt(x*x + 1.0));
std::cout << "Variable value is " << x << std::endl;
std::cout << "Value of function using cmath " << z << std::endl;
std::cout << "Value of function using stdlib " << y << std::endl;
return 0;
}
gives output
Value is -0.546
Value of function using cmath 0.479221
Value of function using stdlib 0
on compiler (GCC) 8.3.1 20191121. Curiously, this is not the output on C++ shell, instead keeping the value of the function non-zero.