From a9110bfc876b00f0cfcb4ef0980ea4125578f057 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sun, 26 Oct 2025 02:03:22 +0000 Subject: [PATCH] Fix ambiguous sqrt() overload caused by ADL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here's the compiler error: ``` /home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Householder/Householder.h:82:16: error: call of overloaded ‘sqrt(boost::decimal::decimal64_t)’ is ambiguous 82 | beta = sqrt(numext::abs2(c0) + tailSqNorm); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Householder/Householder.h:82:16: note: there are 2 candidates In file included from /home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/Core:198, from /home/tav/git/Sleipnir/test/src/optimization/cart_pole_problem_test.cpp:8: /home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Core/MathFunctions.h:1384:75: note: candidate 1: ‘typename Eigen::internal::sqrt_retval::type>::type Eigen::numext::sqrt(const Scalar&) [with Scalar = boost::decimal::decimal64_t; typename Eigen::internal::sqrt_retval::type>::type = boost::decimal::decimal64_t; typename Eigen::internal::global_math_functions_filtering_base::type = boost::decimal::decimal64_t]’ 1384 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x) { | ^~~~ In file included from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/detail/cmath/ellint_1.hpp:16, from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/cmath.hpp:18, from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal.hpp:33, from /home/tav/git/Sleipnir/test/include/scalar_types_under_test.hpp:6, from /home/tav/git/Sleipnir/test/src/optimization/cart_pole_problem_test.cpp:19: /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/detail/cmath/sqrt.hpp:167:16: note: candidate 2: ‘constexpr T boost::decimal::sqrt(T) requires is_decimal_floating_point_v [with T = decimal64_t]’ 167 | constexpr auto sqrt(const T val) noexcept | ^~~~ ``` Calling a function via its unqualified name invokes argument-dependent lookup. In this case, since `using numext::sqrt;` was used, both `numext::sqrt()` and `boost::decimal::sqrt()` participated in overload resolution. Since only `numext::sqrt()` was intended, the fix is to call that overload directly instead. See merge request libeigen/eigen!2044 (cherry picked from commit be56fff1ff288f83296a78d63314a3eeac3397ae) --- Eigen/src/Householder/Householder.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Eigen/src/Householder/Householder.h b/Eigen/src/Householder/Householder.h index 96b1daf5f..e5d2d4fac 100644 --- a/Eigen/src/Householder/Householder.h +++ b/Eigen/src/Householder/Householder.h @@ -65,7 +65,6 @@ template EIGEN_DEVICE_FUNC void MatrixBase::makeHouseholder(EssentialPart& essential, Scalar& tau, RealScalar& beta) const { using numext::conj; - using numext::sqrt; EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart) VectorBlock tail(derived(), 1, size() - 1); @@ -79,7 +78,7 @@ EIGEN_DEVICE_FUNC void MatrixBase::makeHouseholder(EssentialPart& essen beta = numext::real(c0); essential.setZero(); } else { - beta = sqrt(numext::abs2(c0) + tailSqNorm); + beta = numext::sqrt(numext::abs2(c0) + tailSqNorm); if (numext::real(c0) >= RealScalar(0)) beta = -beta; essential = tail / (c0 - beta); tau = conj((beta - c0) / beta);