[Bug libstdc++/13943] New: call of overloaded `llabs(int)' is ambiguous

debian-gcc at lists dot debian dot org gcc-bugzilla@gcc.gnu.org
Sat Jan 31 11:52:00 GMT 2004


[forwarded from http://bugs.debian.org/228645]

on i486-linux, glibc-2.3.2 based.

---
#include <math.h>
#include <cstdlib>

using namespace std;

int foo() { return llabs(1); }
---

g++-3.3 blah.cc -c
blah.cc: In function `int foo()':
blah.cc:6: error: call of overloaded `llabs(int)' is ambiguous
/usr/include/stdlib.h:754: error: candidates are: long long int llabs(long long
   int)
/usr/include/c++/3.3/cstdlib:152: error:                 long long int
   __gnu_cxx::llabs(long long int)

This works in g++ 3.2, but not 3.3 and 3.4.
<vector> pulls in <cstdlib>, so using <math.h> and <vector> together causes
this problem.  That is, it's triggered even if you don't use the <cstdlib>
header: merely mixing vector with math.h triggers it, and it's impossible
to avoid math.h (as library headers often pull it in.)

This doesn't happen with other functions in cstdlib, such as abs().
Comments in /usr/include/c++/3.3/cstdlib indicate that it's intended to
work ("// Get rid of those macros defined in <stdlib.h> ...").

-- 
           Summary: call of overloaded `llabs(int)' is ambiguous
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13943



More information about the Gcc-bugs mailing list