diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-11-20 11:17:33 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-11-20 11:19:38 -0500 |
commit | c0ad05d567796104f55d388b5d5b21da8fa47de2 (patch) | |
tree | 9a550b42f18a09fb75d8e7ae28ecd1e2c20183a9 | |
parent | a43b29c90d8efa1013cb4b6bc49bb78de5e79784 (diff) | |
download | gdb-c0ad05d567796104f55d388b5d5b21da8fa47de2.zip gdb-c0ad05d567796104f55d388b5d5b21da8fa47de2.tar.gz gdb-c0ad05d567796104f55d388b5d5b21da8fa47de2.tar.bz2 |
gdb: fix unittests/gmp-utils-selftests.c build on solaris
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
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/unittests/gmp-utils-selftests.c | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9106860..4663f56 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2020-11-20 Simon Marchi <simon.marchi@polymtl.ca> + * unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small): + Pass 2.0 to pow. + (gdb_mpz_write_all_from_small): Likewise. + +2020-11-20 Simon Marchi <simon.marchi@polymtl.ca> + * dwarf2/read.c (finish_fixed_point_type): Use std::abs instead of abs. diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c index e8c3c5c..af5bc65 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++) { |