Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: error: call of overloaded 'ldexp(long int, int)' is ambiguous #1824

Open
mtelka opened this issue Feb 6, 2025 · 1 comment
Open

Comments

@mtelka
Copy link

mtelka commented Feb 6, 2025

Describe the issue

The compilation of abseil-cpp 20240116.3 fails on OpenIndiana with this error:

In file included from /usr/include/gtest/gtest.h:71,
                 from /data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv_test.cc:25:
/data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv_test.cc: In member function 'virtual void {anonymous}::FromChars_NearRoundingCasesExplicit_Test::TestBody()':
/data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv_test.cc:183:38: error: call of overloaded 'ldexp(long int, int)' is ambiguous
  183 |   EXPECT_EQ(ToDouble("5.e125"), ldexp(6653062250012735, 365));
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/math.h:35,
                 from /usr/gcc/14/include/c++/14.2.0/bits/std_abs.h:40,
                 from /usr/gcc/14/include/c++/14.2.0/cstdlib:81,
                 from /usr/gcc/14/include/c++/14.2.0/ext/string_conversions.h:43,
                 from /usr/gcc/14/include/c++/14.2.0/bits/basic_string.h:4154,
                 from /usr/gcc/14/include/c++/14.2.0/string:54,
                 from /usr/gcc/14/include/c++/14.2.0/stdexcept:39,
                 from /usr/gcc/14/include/c++/14.2.0/system_error:43,
                 from /data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv.h:18,
                 from /data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv_test.cc:15:
/usr/include/iso/math_iso.h:211:28: note: candidate: 'long double std::ldexp(long double, int)'
  211 |         inline long double ldexp(long double __X, int __Y) {
      |                            ^~~~~
/usr/include/iso/math_iso.h:171:22: note: candidate: 'float std::ldexp(float, int)'
  171 |         inline float ldexp(float __X, int __Y) { return __ldexpf(__X, __Y); }
      |                      ^~~~~
/usr/include/iso/math_iso.h:71:15: note: candidate: 'double std::ldexp(double, int)'
   71 | extern double ldexp(double, int);
      |               ^~~~~
/data/builds/oi-userland/components/library/abseil-cpp/abseil-cpp-20240116.3/absl/strings/charconv_test.cc:184:39: error: call of overloaded 'ldexp(long int, int)' is ambiguous
  184 |   EXPECT_EQ(ToDouble("69.e267"), ldexp(4705683757438170, 841));
      |                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/iso/math_iso.h:211:28: note: candidate: 'long double std::ldexp(long double, int)'
  211 |         inline long double ldexp(long double __X, int __Y) {
      |                            ^~~~~
/usr/include/iso/math_iso.h:171:22: note: candidate: 'float std::ldexp(float, int)'
  171 |         inline float ldexp(float __X, int __Y) { return __ldexpf(__X, __Y); }
      |                      ^~~~~
/usr/include/iso/math_iso.h:71:15: note: candidate: 'double std::ldexp(double, int)'
   71 | extern double ldexp(double, int);
      |               ^~~~~

Steps to reproduce the problem

Compile abseil-cpp 20240116.3 with -DABSL_BUILD_TESTING=ON and -DABSL_USE_EXTERNAL_GOOGLETEST=ON on OpenIndiana.

What version of Abseil are you using?

20240116.3

What operating system and version are you using?

OpenIndiana (illumos distro)

What compiler and version are you using?

$ gcc --version
gcc (OpenIndiana 14.2.0-oi-1) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

What build system are you using?

cmake version 3.31.5

Additional context

No response

@mtelka
Copy link
Author

mtelka commented Feb 6, 2025

I worked around the issue by adding .0 to the first parameter of all ldexp() calls in the absl/strings/charconv_test.cc file (44 occurences).

BTW, similar problem is with the pow() call in absl/strings/internal/cord_rep_btree_test.cc. I use this patch as a temporay solution:

--- abseil-cpp-20240116.3/absl/strings/internal/cord_rep_btree_test.cc.orig
+++ abseil-cpp-20240116.3/absl/strings/internal/cord_rep_btree_test.cc
@@ -740,7 +740,7 @@
     std::uniform_int_distribution<int> dist_height(0, 3);
     std::uniform_int_distribution<int> dist_leaf(0, max_cap - 1);
     const int height = dist_height(rnd);
-    return (height ? pow(max_cap, height) : 0) + dist_leaf(rnd);
+    return (height ? pow(static_cast<long double>(max_cap), height) : 0) + dist_leaf(rnd);
   };
 
   for (int i = 0; i < 10000; ++i) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant