From: Pedro Alves <palves@redhat.com>
To: Christian Biesinger <cbiesinger@google.com>
Cc: Andrew Burgess <andrew.burgess@embecosm.com>,
gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types
Date: Thu, 27 Feb 2020 19:26:00 -0000 [thread overview]
Message-ID: <e71e8afd-ae69-ad5e-2e61-ecaef008003d@redhat.com> (raw)
In-Reply-To: <CAPTJ0XEz98WLdGw3=OHREEqg4HkLfs6CjVBFFYqxgbC3yGsL=w@mail.gmail.com>
On 2/27/20 7:09 PM, Christian Biesinger via gdb-patches wrote:
> On Thu, Feb 27, 2020 at 1:07 PM Pedro Alves <palves@redhat.com> 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 <stdlib.h>
#include <stdio.h>
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
next prev parent reply other threads:[~2020-02-27 19:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200227164651.13723-1-andrew.burgess@embecosm.com>
2020-02-27 19:06 ` Pedro Alves
2020-02-27 19:09 ` Christian Biesinger via gdb-patches
2020-02-27 19:26 ` Pedro Alves [this message]
2020-02-27 21:10 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e71e8afd-ae69-ad5e-2e61-ecaef008003d@redhat.com \
--to=palves@redhat.com \
--cc=andrew.burgess@embecosm.com \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox