From owner-freebsd-bugs@FreeBSD.ORG Fri Apr 16 12:30:26 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8405016A4CE for ; Fri, 16 Apr 2004 12:30:26 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6A42C43D54 for ; Fri, 16 Apr 2004 12:30:26 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i3GJUQbv026867 for ; Fri, 16 Apr 2004 12:30:26 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i3GJUQmK026866; Fri, 16 Apr 2004 12:30:26 -0700 (PDT) (envelope-from gnats) Resent-Date: Fri, 16 Apr 2004 12:30:26 -0700 (PDT) Resent-Message-Id: <200404161930.i3GJUQmK026866@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jonathan Lennox Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D38F16A4CE for ; 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 ; 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 ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: gnu/65641: Use of llabs() in C++ fails as ambiguous X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jonathan Lennox List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2004 19:30:26 -0000 >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@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 and __gnu_cxx::llabs(long long), imported into namespace std, from . 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 using namespace std; int main() { long long foo = -1LL, bar; bar = llabs(foo); return 0; } --- llabs.cxx ends here --- >Release-Note: >Audit-Trail: >Unformatted: