BUG: Drop explicit <double> template arg from std::abs in test#600
Merged
Conversation
On macOS SDK 26.5's <__math/abs.h>, the std::abs overload set includes
both the templated floating-point form and integer-typed candidates,
making the explicit form `std::abs<double>(...)` ambiguous:
error: call to 'abs' is ambiguous
37 | return std::abs<double>(input - desired)
| ^~~~~~~~~~~~~~~~
The explicit template argument was never load-bearing here --- inputs
are `double`, so the non-templated `std::abs(double)` overload from
<cmath> resolves unambiguously. Dropping `<double>` fixes the build
on current Apple toolchains without changing behavior on earlier
SDKs or other platforms.
Surfaced while validating BRAINSia#598 (find_package(ANTS)
migration) on AppleClang 21 / macOS SDK 26.5.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop the explicit
<double>template argument fromstd::absinitkResampleInPlaceImageFilterTest.cxx, which became ambiguous on macOS SDK 26.5 / AppleClang 21 and broke the test build.Root cause
macOS SDK 26.5's libc++ exposes the
std::absoverload set via<__math/abs.h>, where theint/long/long longoverloads plus the floating-point template are all visible. Writingstd::abs<double>(...)forces template-argument deduction and leaves the integer candidates viable, so overload resolution is ambiguous:The explicit template argument was never load-bearing: the inputs are
double, so the non-templatestd::abs(double)from<cmath>is an exact match and resolves unambiguously. Dropping<double>fixes the build on current Apple toolchains with no behavior change on earlier SDKs or other platforms.Surfaced while validating #598 (find_package(ANTS) migration) on AppleClang 21 / macOS SDK 26.5.
Local validation
Verified on the exact toolchain that surfaced the bug (Apple clang 21.0.0, arm64-apple-darwin25.5.0), compiling via
ccache clang++ -std=c++17:std::abs<double>(...)→error: call to 'abs' is ambiguous(candidates from MacOSX.sdk<__math/abs.h>).std::abs(...)→ compiles cleanly (exit 0).pre-commit run --all-filespasses.