When compiling the source below, g++ 3.4 gives the errors:
$ g++ -c x.cc
x.cc: In function `double foo(double)':
x.cc:8: error: call of overloaded `abs(double&)' is ambiguous
/usr/include/stdlib.h:699: error: candidates are: int abs(int)
/usr/local/gcc/include/c++/3.4/cstdlib:142: error: long long
int __gnu_cxx::abs(long long int)
The error goes away if i reverse the order of the two includes
(putting cstdlib before cmath) or if i explicitly qualify the abs()
call with std::.
This source compiles without error with g++ 3.1.
3.4 20030121 (experimental)
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
<machine, os, target, libraries (multiple lines)>
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long
double foo (double x)
return abs (x);
<how to correct or work around the problem, if known (multiple lines)>
State-Changed-Why: Confirmed. The reason is that until 3.3, the overload
was chosen, which is an exact match (one can see that it
was chosen by looking at the output of the compiler with
nm -C). Somehow this overload must have vanished from
the list of overloads considered.
This still happens on the mainline (20030607).
Same bug as PR 11409 which has more analysis.
*** This bug has been marked as a duplicate of 11409 ***