Message ID | 20191219000103.36667-4-cbiesinger@google.com |
---|---|
State | New |
Headers | show |
> 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.
>>>>> "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
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
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; }