From mboxrd@z Thu Jan 1 00:00:00 1970 From: pete@toyon.com To: gcc-gnats@gcc.gnu.org Cc: bkoz@gcc.gnu.org Subject: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument. Date: Wed, 13 Jun 2001 16:46:00 -0000 Message-id: <20010613234142.8626.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00613.html List-Id: >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 #include 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; }