libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
pete@toyon.com
pete@toyon.com
Wed Jun 13 16:46:00 GMT 2001
>Number: 3181
>Category: libstdc++
>Synopsis: Unable to use sqrt,cos,sin,... with int argument.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jun 13 16:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Pete Stieber
>Release: gcc version 3.1 20010611 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
Red Hat 7.1
>Description:
Error compiling std library math functions with in arguments. Automatic type conversion not working:
test.cpp: In function `int main()':
test.cpp:11: call of overloaded `sqrt(int&)' is ambiguous
/usr/include/bits/mathcalls.h:146: candidates are: double sqrt(double)
/usr/local/include/g++-v3/bits/std_cmath.h:461: long double std::sqrt(long double)
/usr/local/include/g++-v3/bits/std_cmath.h:455: float std::sqrt(float)
>How-To-Repeat:
gcc test.cpp
>Fix:
I have to cast int/long/... instead of automatic conversion.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.cpp"
Content-Disposition: inline; filename="test.cpp"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int i = -1;
double Ans;
// All of the functions have the problem, but we will use sqrt to illustrate.
Ans = sqrt(i);
cout << Ans << endl;
// Ans = cos(i);
// cout << Ans << endl;
// Ans = sin(i);
// cout << Ans << endl;
// Ans = tan(i);
// cout << Ans << endl;
// Ans = acos(i);
// cout << Ans << endl;
// Ans = asin(i);
// cout << Ans << endl;
// Ans = atan(i);
// cout << Ans << endl;
return 1;
}
More information about the Gcc-bugs
mailing list