libstdc++ change breaks simple code
Mixtim
mixtim@home.com
Fri May 25 20:43:00 GMT 2001
Here is the code in question:
#include <cmath>
using namespace std;
int
main()
{
double d = sqrt(1.0);
return 0;
}
gcc version 3.0 20010520 (prerelease) compiles this fine.
gcc version 3.0 20010525 (prerelease) barfs.
mixtim@cg392862-a ~/work> g++ test.cc
test.cc: In function `int main()':
test.cc:8: call of overloaded `__glibcpp_sqrt(double)' is ambiguous
/home/mixtim/gcc/lib/gcc-lib/i386-unknown-freebsd4.3/3.0/include/math.h:135: candidates
are: double __glibcpp_sqrt(double)
/home/mixtim/gcc/include/g++-v3/bits/std_cmath.h:528: long
double std::__glibcpp_sqrt(long double)
/home/mixtim/gcc/include/g++-v3/bits/std_cmath.h:524: double
std::__glibcpp_sqrt(double)
/home/mixtim/gcc/include/g++-v3/bits/std_cmath.h:520: float
std::__glibcpp_sqrt(float)
gcc version 3.0 20010520 has the following defs for sqrt:
#if _GLIBCPP_HAVE___BUILTIN_SQRTF
inline float
sqrt(float __x) { return __builtin_sqrtf(__x); }
#elif _GLIBCPP_HAVE_SQRTF
inline float
sqrt(float __x) { return ::sqrtf(__x); }
#else
inline float
sqrt(float __x) { return ::sqrt(static_cast<double>(__x)); }
#endif
while gcc version 3.0 20010525 has the following:
// sqrt.
inline float
sqrt(float __x)
{ return __builtin_sqrtf(__x); }
inline double
sqrt(double __x)
{ return __builtin_fsqrt(__x); }
inline long double
sqrt(long double __x)
{ return __builtin_sqrtl(__x); }
Why was this done?
More information about the Gcc
mailing list