Patchwork [3/3] Make the literal argument to pow a double, not an integer

login
register
mail settings
Submitter Doug Evans via gdb-patches
Date Dec. 19, 2019, 12:01 a.m.
Message ID <20191219000103.36667-5-cbiesinger@google.com>
Download mbox | patch
Permalink /patch/36955/
State New
Headers show

Comments

Doug Evans via gdb-patches - Dec. 19, 2019, 12:01 a.m.
Since pow takes doubles, pass 2.0 instead of 2 to pow ().

Conveniently, this fixes the ambiguous call to pow on Solaris 11
with gcc 5.5 (gcc211 on the compile farm), which has a "using std::pow"
directive in a system header, which brings in float/double/long double
overloads.  Fixes the build on Solaris with enable-targets=all.

gdb/ChangeLog:

2019-12-18  Christian Biesinger  <cbiesinger@google.com>

	* score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
	2 to pow ().

Change-Id: Ib18e7e4749ddcbff0727b72a31198f8cb84d1993
---
 gdb/score-tdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Tom Tromey - Dec. 19, 2019, 6:19 p.m.
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> 2019-12-18  Christian Biesinger  <cbiesinger@google.com>

Christian> 	* score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
Christian> 	2 to pow ().

It probably makes sense to add a comment about Solaris here as well.
It's a bit borderline for me, considering it is a constant, but on the
other hand, a comment is definitely safe.  So, ok with that change.

thanks,
Tom
Doug Evans via gdb-patches - Dec. 19, 2019, 7:13 p.m.
On Thu, Dec 19, 2019 at 12:19 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> 2019-12-18  Christian Biesinger  <cbiesinger@google.com>
>
> Christian>      * score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of
> Christian>      2 to pow ().
>
> It probably makes sense to add a comment about Solaris here as well.
> It's a bit borderline for me, considering it is a constant, but on the
> other hand, a comment is definitely safe.  So, ok with that change.

OK, added this comment:
+             /* Solaris 11+gcc 5.5 has ambiguous overloads of pow, so we
+                pass 2.0 instead of 2 to get the right one.  */

Christian

Patch

diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 5ca763c40f..691051729e 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -918,13 +918,13 @@  score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* subei! r0, n */
-              sp_offset += (int) pow (2, G_FLD (inst->v, 6, 3));
+              sp_offset += (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
           else if (G_FLD (inst->v, 14, 7) == 0xc0
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* addei! r0, n */
-              sp_offset -= (int) pow (2, G_FLD (inst->v, 6, 3));
+              sp_offset -= (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
         }
       else