* Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types
[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 21:10 ` Andrew Burgess
0 siblings, 2 replies; 4+ messages in thread
From: Pedro Alves @ 2020-02-27 19:06 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
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.
>
> There should be no user visible change after this commit.
>
> gdb/ChangeLog:
>
> * gdbtypes.c (create_array_type_with_stride): Use std::abs not
> abs.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types
2020-02-27 19:06 ` [PUSHED] gdb: Use std::abs instead of abs on LONGEST types Pedro Alves
@ 2020-02-27 19:09 ` Christian Biesinger via gdb-patches
2020-02-27 19:26 ` Pedro Alves
2020-02-27 21:10 ` Andrew Burgess
1 sibling, 1 reply; 4+ messages in thread
From: Christian Biesinger via gdb-patches @ 2020-02-27 19:09 UTC (permalink / raw)
To: Pedro Alves; +Cc: Andrew Burgess, gdb-patches
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.
Christian
>
> >
> > There should be no user visible change after this commit.
> >
> > gdb/ChangeLog:
> >
> > * gdbtypes.c (create_array_type_with_stride): Use std::abs not
> > abs.
>
> Thanks,
> Pedro Alves
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types
2020-02-27 19:09 ` Christian Biesinger via gdb-patches
@ 2020-02-27 19:26 ` Pedro Alves
0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2020-02-27 19:26 UTC (permalink / raw)
To: Christian Biesinger; +Cc: Andrew Burgess, gdb-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PUSHED] gdb: Use std::abs instead of abs on LONGEST types
2020-02-27 19:06 ` [PUSHED] gdb: Use std::abs instead of abs on LONGEST types Pedro Alves
2020-02-27 19:09 ` Christian Biesinger via gdb-patches
@ 2020-02-27 21:10 ` Andrew Burgess
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2020-02-27 21:10 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
* Pedro Alves <palves@redhat.com> [2020-02-27 19:06:47 +0000]:
> 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.
Thanks for looking at this.
Thanks,
Andrew
>
> >
> > There should be no user visible change after this commit.
> >
> > gdb/ChangeLog:
> >
> > * gdbtypes.c (create_array_type_with_stride): Use std::abs not
> > abs.
>
> Thanks,
> Pedro Alves
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-27 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200227164651.13723-1-andrew.burgess@embecosm.com>
2020-02-27 19:06 ` [PUSHED] gdb: Use std::abs instead of abs on LONGEST types Pedro Alves
2020-02-27 19:09 ` Christian Biesinger via gdb-patches
2020-02-27 19:26 ` Pedro Alves
2020-02-27 21:10 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox