Can someone pass this bug report to whoever handles bugs in the compiler since I have failed to find any way of reporting bugs.
Both cout << x and log(x) give wrong answers when x is declared long double. But various other functions including log10 are fine.
Here is the test program
int main()
{
{
cout << "Declaring two as double"<< endl;
double two = 2;
double sqrt2 = (double)sqrt(two);
double log2 = (double)log(two);
double log10_2 = (double)log10(two);
double exp2 = (double)exp(two);
cout << "two "<< two << endl;
cout << "sqrt(two) "<< sqrt2 << endl;
cout << "log(two) "<< log2 << endl;
cout << "log10(two) "<< log10_2 << endl;
cout << "exp(two) "<< exp2 << endl;
cout << endl;
}
{
cout << "Declaring two as long double"<< endl;
long double two = 2;
double sqrt2 = (double)sqrt(two);
double log2 = (double)log(two);
double log10_2 = (double)log10(two);
double exp2 = (double)exp(two);
cout << "two "<< two << endl;
cout << "sqrt(two) "<< sqrt2 << endl;
cout << "log(two) "<< log2 << endl;
cout << "log10(two) "<< log10_2 << endl;
cout << "exp(two) "<< exp2 << endl;
cout << endl;
}
return 0;
and here is the output
Declaring two as double
two 2
sqrt(two) 1.41421
log(two) 0.693147
log10(two) 0.30103
exp(two) 7.38906
Declaring two as long double
two 1.38893e-312
sqrt(two) 1.41421
log(two) -nan(ind)
log10(two) 0.30103
exp(two) 7.38906
This happens with both the 2018 and 2019 versions of the compiler. This is the line in the make file calling the compiler
icl -Qstd=c++17 -c -EHsc -GR -Ge -GS -Qprec -Qprec_div -nologo -Qlong_double -fp:precise $*.cpp -D__builtin_huge_val()=HUGE_VAL -D__builtin_huge_valf()=HUGE_VALF -D__builtin_nan=nan -D__builtin_nanf=nanf -D__builtin_nans=nan -D__builtin_nansf=nanf
It looks like a compiler bug rather than my error but it would be nice if anyone can assist.
Robert