From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2252 invoked by alias); 27 Feb 2020 19:26:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2241 invoked by uid 89); 27 Feb 2020 19:26:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1323, H*f:sk:CAPTJ0X, H*i:sk:CAPTJ0X, H*i:sk:OHREEqg X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 19:26:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582831608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E0RchwtTUFgnj2gz/Lq+VcxFn79ireWjtnzpyA3DLK0=; b=e7nBOM2mYU9d25f1/YSUfUjAyj12sT7P/t3BO+YnRPO6wIjOgTfWzMHyuTWulyo5iNWtHr sRSyJvZShAxfFYFdIVzn2OwQzcFccaqWDP7403RtltN2yZ+viG70J2U6sb/Ztpbkdfuuyv 9N8O1LZEuaHVCeRRWKDKQ/UIb+LhAGA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-uwna-VgWNH6lb4KcjiOK2A-1; Thu, 27 Feb 2020 14:26:41 -0500 Received: by mail-wr1-f71.google.com with SMTP id z15so265978wrw.0 for ; Thu, 27 Feb 2020 11:26:41 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id z14sm9116801wru.31.2020.02.27.11.26.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Feb 2020 11:26:39 -0800 (PST) Subject: Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types To: Christian Biesinger References: <20200227164651.13723-1-andrew.burgess@embecosm.com> <09b7ad54-6c4f-922e-9a72-9e3d26603aec@redhat.com> Cc: Andrew Burgess , gdb-patches From: Pedro Alves Message-ID: Date: Thu, 27 Feb 2020 19:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg01022.txt.bz2 On 2/27/20 7:09 PM, Christian Biesinger via gdb-patches wrote: > On Thu, Feb 27, 2020 at 1:07 PM Pedro Alves wrote: >> >> On 2/27/20 4:46 PM, Andrew Burgess wrote: >>> Use std::abs so that we get the C++ overloaded version that matches >>> the argument type instead of the C abs function which is only for int >>> arguments. >> >> Note that stdlib.h/stdmath.h are supposed to provide the overloads in >> the global namespace as well; the standard requires it. Older >> GCCs got that wrong (e.g. 4.8), but more modern GCCs get it right. >> >> Just a FYI, the patch is fine. > > Hm... I saw a build error from this on arm-netbsd with clang 9, I > wonder what happened there. Anyway, the patch does fix it. > ( See: https://developers.redhat.com/blog/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/ ) Odd, clang 5, which is what I have handy, gets it right: $ cat abs.cc #include #include void foo (long i) { printf ("long\n"); } void foo (int i) { printf ("int\n"); } int main () { foo (abs ((long)1)); foo (abs ((int)1)); } $ clang++ abs.cc -o abs && ./abs long int I wonder whether you were seeing a gnulib override issue, but I can't find an abs override in our import. Thanks, Pedro Alves