* [PATCH 1/2] gdb: fix dwarf2/read.c build on solaris
@ 2020-11-19 17:13 Simon Marchi
2020-11-19 17:14 ` [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c " Simon Marchi
2020-11-20 15:29 ` [PATCH 1/2] gdb: fix dwarf2/read.c " Tom Tromey
0 siblings, 2 replies; 6+ messages in thread
From: Simon Marchi @ 2020-11-19 17:13 UTC (permalink / raw)
To: gdb-patches
When building on solaris (gcc farm machine gcc211), I get:
CXX dwarf2/read.o
/export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function ‘void finish_fixed_point_type(type*, die_info*, dwarf2_cu*)’:
/export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:18204:42: error: call of overloaded ‘abs(LONGEST&)’ is ambiguous
*num_or_denom = 1 << abs (scale_exp);
^
In file included from /usr/include/stdlib.h:11:0,
from ../gnulib/import/stdlib.h:36,
from /opt/csw/include/c++/5.5.0/cstdlib:72,
from /export/home/simark/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:90,
from /export/home/simark/src/binutils-gdb/gdb/defs.h:28,
from /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:31:
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:163:16: note: candidate: long int std::abs(long int)
inline long abs(long _l) { return labs(_l); }
^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:117:12: note: candidate: int std::abs(int)
extern int abs(int);
^
I don't know why, but using std::abs instead of just abs fixes it.
gdb/ChangeLog:
* dwarf2/read.c (finish_fixed_point_type): Use std::abs instead
of abs.
Change-Id: I57b9098351f2a8b2d2f61e848b97f7b2dfe55908
---
gdb/dwarf2/read.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3c598262913f..f87975371083 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18201,14 +18201,14 @@ finish_fixed_point_type (struct type *type, struct die_info *die,
LONGEST scale_exp = attr->constant_value (0);
ULONGEST *num_or_denom = scale_exp > 0 ? &scale_num : &scale_denom;
- *num_or_denom = 1 << abs (scale_exp);
+ *num_or_denom = 1 << std::abs (scale_exp);
}
else if (attr->name == DW_AT_decimal_scale)
{
LONGEST scale_exp = attr->constant_value (0);
ULONGEST *num_or_denom = scale_exp > 0 ? &scale_num : &scale_denom;
- *num_or_denom = uinteger_pow (10, abs (scale_exp));
+ *num_or_denom = uinteger_pow (10, std::abs (scale_exp));
}
else if (attr->name == DW_AT_small)
{
--
2.29.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c build on solaris
2020-11-19 17:13 [PATCH 1/2] gdb: fix dwarf2/read.c build on solaris Simon Marchi
@ 2020-11-19 17:14 ` Simon Marchi
2020-11-20 15:31 ` Tom Tromey
2020-11-20 15:29 ` [PATCH 1/2] gdb: fix dwarf2/read.c " Tom Tromey
1 sibling, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2020-11-19 17:14 UTC (permalink / raw)
To: gdb-patches
When building on solaris (gcc farm machine gcc211), I get:
CXX unittests/gmp-utils-selftests.o
/export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c: In function ‘void selftests::gdb_mpz_read_all_from_small()’ :
/export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c:128:43: error: call of overloaded ‘pow(int, int)’ is ambiguous
LONGEST l_min = -pow (2, buf_len * 8 - 1);
^
In file included from /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:22:0,
from ../gnulib/import/math.h:27,
from /export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c:23:
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:210:21: note: candidate: long double std::pow(long double, long double)
inline long double pow(long double __X, long double __Y) { return
^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:170:15: note: candidate: float std::pow(float, float)
inline float pow(float __X, float __Y) { return __powf(__X, __Y); }
^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:71:15: note: candidate: double std::pow(double, double)
extern double pow __P((double, double));
^
The "pow" function overloads only exist for float-like types, and the
compiler doesn't know which one we want. Change "2" for "2.0", which
makes the compiler choose one alternative (the double one, I believe).
gdb/ChangeLog:
* unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small):
Pass 2.0 to pow.
(gdb_mpz_write_all_from_small): Likewise.
Change-Id: Ied2ae0f01494430244a7c94f8a38b07d819f4213
---
gdb/unittests/gmp-utils-selftests.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c
index e8c3c5c1cb5f..af5bc65d2f94 100644
--- a/gdb/unittests/gmp-utils-selftests.c
+++ b/gdb/unittests/gmp-utils-selftests.c
@@ -125,8 +125,8 @@ gdb_mpz_read_all_from_small ()
to check the complete range. */
int buf_len = 1;
- LONGEST l_min = -pow (2, buf_len * 8 - 1);
- LONGEST l_max = pow (2, buf_len * 8 - 1) - 1;
+ LONGEST l_min = -pow (2.0, buf_len * 8 - 1);
+ LONGEST l_max = pow (2.0, buf_len * 8 - 1) - 1;
for (LONGEST l = l_min; l <= l_max; l++)
{
@@ -141,7 +141,7 @@ gdb_mpz_read_all_from_small ()
/* Do the same as above, but with an unsigned type. */
ULONGEST ul_min = 0;
- ULONGEST ul_max = pow (2, buf_len * 8) - 1;
+ ULONGEST ul_max = pow (2.0, buf_len * 8) - 1;
for (ULONGEST ul = ul_min; ul <= ul_max; ul++)
{
@@ -248,8 +248,8 @@ static void
gdb_mpz_write_all_from_small ()
{
int buf_len = 1;
- LONGEST l_min = -pow (2, buf_len * 8 - 1);
- LONGEST l_max = pow (2, buf_len * 8 - 1) - 1;
+ LONGEST l_min = -pow (2.0, buf_len * 8 - 1);
+ LONGEST l_max = pow (2.0, buf_len * 8 - 1) - 1;
for (LONGEST l = l_min; l <= l_max; l++)
{
@@ -259,7 +259,7 @@ gdb_mpz_write_all_from_small ()
/* Do the same as above, but with an unsigned type. */
ULONGEST ul_min = 0;
- ULONGEST ul_max = pow (2, buf_len * 8) - 1;
+ ULONGEST ul_max = pow (2.0, buf_len * 8) - 1;
for (ULONGEST ul = ul_min; ul <= ul_max; ul++)
{
--
2.29.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] gdb: fix dwarf2/read.c build on solaris
2020-11-19 17:13 [PATCH 1/2] gdb: fix dwarf2/read.c build on solaris Simon Marchi
2020-11-19 17:14 ` [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c " Simon Marchi
@ 2020-11-20 15:29 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2020-11-20 15:29 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> I don't know why, but using std::abs instead of just abs fixes it.
We've had a couple of other patches related to std::abs, but neither of
those seems to be exactly the same.
Simon> gdb/ChangeLog:
Simon> * dwarf2/read.c (finish_fixed_point_type): Use std::abs instead
Simon> of abs.
This seems fine to me.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c build on solaris
2020-11-19 17:14 ` [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c " Simon Marchi
@ 2020-11-20 15:31 ` Tom Tromey
2020-11-20 16:08 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2020-11-20 15:31 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> The "pow" function overloads only exist for float-like types, and the
Simon> compiler doesn't know which one we want. Change "2" for "2.0", which
Simon> makes the compiler choose one alternative (the double one, I believe).
Simon> gdb/ChangeLog:
Simon> * unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small):
Simon> Pass 2.0 to pow.
Simon> (gdb_mpz_write_all_from_small): Likewise.
This seems fine, though I wonder if it should use std::pow.
I guess I'm a little surprised that ordinary 'pow' has overloads.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c build on solaris
2020-11-20 15:31 ` Tom Tromey
@ 2020-11-20 16:08 ` Simon Marchi
2020-11-20 16:31 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2020-11-20 16:08 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi via Gdb-patches
On 2020-11-20 10:31 a.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> The "pow" function overloads only exist for float-like types, and the
> Simon> compiler doesn't know which one we want. Change "2" for "2.0", which
> Simon> makes the compiler choose one alternative (the double one, I believe).
>
> Simon> gdb/ChangeLog:
>
> Simon> * unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small):
> Simon> Pass 2.0 to pow.
> Simon> (gdb_mpz_write_all_from_small): Likewise.
>
> This seems fine, though I wonder if it should use std::pow.
> I guess I'm a little surprised that ordinary 'pow' has overloads.
It doesn't seem to matter whether I used the std:: prefix or not. Since
we include <math.h>, the entities provided by that file are necessarily
put in the global namespace:
https://en.cppreference.com/w/cpp/header#C_compatibility_headers
So just using 'pow' considers all std::pow overloads.
My only question is why with libstdc++, we don't have this problem (an
overload is automatically chosen), but we do with Oracle's libCstd:
https://www.oracle.com/solaris/technologies/cmp-stlport-libcstd.html
I'll push both patches now, thanks for the reviews.
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c build on solaris
2020-11-20 16:08 ` Simon Marchi
@ 2020-11-20 16:31 ` Pedro Alves
0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2020-11-20 16:31 UTC (permalink / raw)
To: Simon Marchi, Tom Tromey, Simon Marchi via Gdb-patches
On 11/20/20 4:08 PM, Simon Marchi via Gdb-patches wrote:
> On 2020-11-20 10:31 a.m., Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Simon> The "pow" function overloads only exist for float-like types, and the
>> Simon> compiler doesn't know which one we want. Change "2" for "2.0", which
>> Simon> makes the compiler choose one alternative (the double one, I believe).
>>
>> Simon> gdb/ChangeLog:
>>
>> Simon> * unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small):
>> Simon> Pass 2.0 to pow.
>> Simon> (gdb_mpz_write_all_from_small): Likewise.
>>
>> This seems fine, though I wonder if it should use std::pow.
>> I guess I'm a little surprised that ordinary 'pow' has overloads.
>
> It doesn't seem to matter whether I used the std:: prefix or not. Since
> we include <math.h>, the entities provided by that file are necessarily
> put in the global namespace:
>
> https://en.cppreference.com/w/cpp/header#C_compatibility_headers
>
> So just using 'pow' considers all std::pow overloads.
>
> My only question is why with libstdc++, we don't have this problem (an
> overload is automatically chosen), but we do with Oracle's libCstd:
>
> https://www.oracle.com/solaris/technologies/cmp-stlport-libcstd.html
See this excellent blog post from Jonathan Wakely:
https://developers.redhat.com/blog/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-20 16:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 17:13 [PATCH 1/2] gdb: fix dwarf2/read.c build on solaris Simon Marchi
2020-11-19 17:14 ` [PATCH 2/2] gdb: fix unittests/gmp-utils-selftests.c " Simon Marchi
2020-11-20 15:31 ` Tom Tromey
2020-11-20 16:08 ` Simon Marchi
2020-11-20 16:31 ` Pedro Alves
2020-11-20 15:29 ` [PATCH 1/2] gdb: fix dwarf2/read.c " Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).