This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/9396: ambiguities with abs()


>Number:         9396
>Category:       libstdc++
>Synopsis:       ambiguities with abs()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 22 04:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.4 20030121 (experimental)
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
Architecture: i686

	<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long
>Description:

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.


>How-To-Repeat:

---------------------------
#include <cmath>
#include <cstdlib>

using std::abs;

double foo (double x)
{
  return abs (x);
}

---------------------------

>Fix:
	<how to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]