gnu/65641: Use of llabs() in C++ fails as ambiguous
Jonathan Lennox
lennox at cs.columbia.edu
Fri Apr 16 12:30:26 PDT 2004
>Number: 65641
>Category: gnu
>Synopsis: Use of llabs() in C++ fails as ambiguous
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Apr 16 12:30:25 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator: Jonathan Lennox
>Release: FreeBSD 5.2.1-RELEASE-p3 i386
>Organization:
Columbia University
>Environment:
System: FreeBSD cnr.cs.columbia.edu 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #4: Thu Mar 18 16:03:39 EST 2004 lennox at cnr.cs.columbia.edu:/usr/obj/usr/src/sys/CNR i386
>Description:
When I compile the program llabs.cxx (attached below) with the system g++ on
FreeBSD 5.2.1, it fails with:
llabs.cxx: In function `int main()':
llabs.cxx:9: error: call of overloaded `llabs(long long int&)' is ambiguous
/usr/include/stdlib.h:140: 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 seems to be because it is picking up both ::llabs(long long) from
<stdlib.h> and __gnu_cxx::llabs(long long), imported into namespace std,
from <cstdlib>.
I don't know whether this is a problem with the baseline G++ or G++ as
imported into FreeBSD; if it's the former, please report this to the GCC
people (or I can).
>How-To-Repeat:
g++ llabs.cxx -o llabs
>Fix:
Unknown.
As a workaround, explicitly qualify the call to llabs as std::llabs(). Note
that this is not actually correct C++, though, since llabs is not defined by
the C++98 standard, and thus may not be portable.
--- llabs.cxx begins here ---
#include <cstdlib>
using namespace std;
int main()
{
long long foo = -1LL, bar;
bar = llabs(foo);
return 0;
}
--- llabs.cxx ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list