[2/3] Cast the log10 argument to double to disambiguate it

Message ID 20191219000103.36667-4-cbiesinger@google.com
State New, archived
Headers

Commit Message

Terekhov, Mikhail via Gdb-patches Dec. 19, 2019, 12:01 a.m. UTC
  On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
using std::log10; directive. This is unfortunate because std::log10 has
overloads for float/double/long double. To disambiguate this call,
cast the argument to double to fix the build.

Change-Id: I6c0c52e9c172b529c899a435d430e5916aeef69f
---
 gdb/tui/tui-source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Eli Zaretskii Dec. 19, 2019, 3:35 a.m. UTC | #1
> Date: Wed, 18 Dec 2019 18:01:02 -0600
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
> 
> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
> using std::log10; directive. This is unfortunate because std::log10 has
> overloads for float/double/long double. To disambiguate this call,
> cast the argument to double to fix the build.

We may wish to have a comment in the code referring to the original
problem, including perhaps the OS and the compiler versions?
Otherwise the need for this cast is not immediately obvious, IMO.

Thanks.
  
Tom Tromey Dec. 19, 2019, 6:17 p.m. UTC | #2
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Wed, 18 Dec 2019 18:01:02 -0600
>> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
>> Cc: Christian Biesinger <cbiesinger@google.com>
>> 
>> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
>> using std::log10; directive. This is unfortunate because std::log10 has
>> overloads for float/double/long double. To disambiguate this call,
>> cast the argument to double to fix the build.

Eli> We may wish to have a comment in the code referring to the original
Eli> problem, including perhaps the OS and the compiler versions?
Eli> Otherwise the need for this cast is not immediately obvious, IMO.

Agreed; this is ok with that change.

Tom
  
Terekhov, Mikhail via Gdb-patches Dec. 19, 2019, 7:11 p.m. UTC | #3
On Thu, Dec 19, 2019 at 12:17 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> >> Date: Wed, 18 Dec 2019 18:01:02 -0600
> >> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> >> Cc: Christian Biesinger <cbiesinger@google.com>
> >>
> >> On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a
> >> using std::log10; directive. This is unfortunate because std::log10 has
> >> overloads for float/double/long double. To disambiguate this call,
> >> cast the argument to double to fix the build.
>
> Eli> We may wish to have a comment in the code referring to the original
> Eli> problem, including perhaps the OS and the compiler versions?
> Eli> Otherwise the need for this cast is not immediately obvious, IMO.
>
> Agreed; this is ok with that change.

OK, will push with this comment:
      /* Solaris 11+gcc 5.5 has ambiguous overloads of log10, so we
         cast to double to get the right one.  */

Christian
  

Patch

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 32877d7bc8..1274e81674 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -85,7 +85,7 @@  tui_source_window::set_contents (struct gdbarch *arch,
 	  int digits = 0;
 	  if (compact_source)
 	    {
-	      double l = log10 (offsets->size ());
+	      double l = log10 ((double) offsets->size ());
 	      digits = 1 + (int) l;
 	    }