From lennox@cs.columbia.edu  Fri Apr 16 12:29:04 2004
Return-Path: <lennox@cs.columbia.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0D38F16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 12:29:04 -0700 (PDT)
Received: from cs.columbia.edu (cs.columbia.edu [128.59.16.20])
	by mx1.FreeBSD.org (Postfix) with ESMTP id ABD9E43D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 12:29:03 -0700 (PDT)
	(envelope-from lennox@cs.columbia.edu)
Received: from cnr.cs.columbia.edu (cnr.cs.columbia.edu [128.59.19.133])
	by cs.columbia.edu (8.12.10/8.12.10) with ESMTP id i3GJSfaH003504
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 15:28:41 -0400 (EDT)
Received: from cnr.cs.columbia.edu (localhost [127.0.0.1])
	by cnr.cs.columbia.edu (8.12.10/8.12.10) with ESMTP id i3GJSfTl026741
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Apr 2004 15:28:41 -0400 (EDT)
	(envelope-from lennox@cnr.cs.columbia.edu)
Received: (from lennox@localhost)
	by cnr.cs.columbia.edu (8.12.10/8.12.10/Submit) id i3GJSeKD026740;
	Fri, 16 Apr 2004 15:28:40 -0400 (EDT)
	(envelope-from lennox)
Message-Id: <200404161928.i3GJSeKD026740@cnr.cs.columbia.edu>
Date: Fri, 16 Apr 2004 15:28:40 -0400 (EDT)
From: Jonathan Lennox <lennox@cs.columbia.edu>
Reply-To: Jonathan Lennox <lennox@cs.columbia.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Use of llabs() in C++ fails as ambiguous
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         65641
>Category:       gnu
>Synopsis:       Use of llabs() in C++ fails as ambiguous
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 16 12:30:25 PDT 2004
>Closed-Date:    Mon Jan 14 08:54:12 UTC 2008
>Last-Modified:  Mon Jan 14 08:54:12 UTC 2008
>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@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:

From: Pieter de Goeje <pieter@degoeje.nl>
To: bug-followup@freebsd.org, lennox@cs.columbia.edu
Cc:  
Subject: Re: gnu/65641: Use of llabs() in C++ fails as ambiguous
Date: Sat, 12 Jan 2008 19:27:23 +0100

 Test program works fine on FreeBSD 7. It seems the problem was fixed in GCC 
 4.2.
 
 - Pieter de Goeje
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Sat Jan 12 18:39:07 UTC 2008 
State-Changed-Why:  
Note that submitter has been asked for feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65641 
State-Changed-From-To: feedback->closed 
State-Changed-By: remko 
State-Changed-When: Mon Jan 14 08:54:11 UTC 2008 
State-Changed-Why:  
This seems to have been fixed by recent freebsd versions 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65641 
>Unformatted:
