Skip to content

COMP: Fix ill-formed std::abs<double> in ConditionalMedianImageFilter - #975

Merged
SimonRit merged 1 commit into
RTKConsortium:mainfrom
hjmjohnson:fix-conditionalmedian-abs
Jul 23, 2026
Merged

COMP: Fix ill-formed std::abs<double> in ConditionalMedianImageFilter#975
SimonRit merged 1 commit into
RTKConsortium:mainfrom
hjmjohnson:fix-conditionalmedian-abs

Conversation

@hjmjohnson

Copy link
Copy Markdown
Contributor

std::abs has no function-template overload that accepts an explicit template argument, so std::abs<double>(x) is ill-formed. Conforming compilers (e.g. Apple clang) reject it as an ambiguous call, breaking any consumer that instantiates ConditionalMedianImageFilter. This computes the difference in double and calls the unambiguous std::abs(double) overload.

Context

Introduced by commit 3936486 ("COMP: Drop use of itk::Math::Absolute to fix compilation warnings"), which replaced itk::Math::Absolute(...) with std::abs<double>(...). The surrounding arithmetic (sum, mean, stdev) is already computed in double, so casting the pixel-difference to double and calling std::abs(double) matches the intended semantics and remains warning-free.

Discovered while building RTK as an ITK remote module with Apple clang, where every translation unit including rtkConditionalMedianImageFilter.hxx failed with call to 'abs' is ambiguous. Verified locally: rebuilt RTK application/test targets with this change; the errors are cleared.

std::abs has no function-template overload accepting an explicit
template argument, so std::abs<double>(x) is ill-formed and rejected
as an ambiguous call by conforming compilers (e.g. Apple clang).
Compute the difference in double and call the unambiguous
std::abs(double) overload.

@SimonRit SimonRit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I don't understand why we didn't detect this problem before.

@SimonRit
SimonRit merged commit beb24c1 into RTKConsortium:main Jul 23, 2026
23 checks passed
hjmjohnson added a commit to InsightSoftwareConsortium/ITK that referenced this pull request Jul 23, 2026
Update remote-module GIT_TAG pins to their upstream default-branch HEAD
to reduce drift and pick up maintenance since the last bump.

RTK, SphinxExamples, TubeTK, Cleaver, and TractographyTRX are left at
their existing pins: RTK and TractographyTRX await upstream fixes
(RTKConsortium/RTK#975, tee-ar-ex/ITKTractographyTRX#30), TubeTK has an
upstream header/implementation mismatch, SphinxExamples is only
verifiable via its standalone build, and Cleaver's bundled GoogleTest
collides with ITK's when BUILD_TESTING is on.

Verified by a clean Release build of the 8 buildable updated modules
(zero build failures). CudaCommon, IOOpenSlide, and Ultrasound are
advanced but only exercisable in CI (no CUDA / OpenSlide / a compatible
VTK on the local macOS host).
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

Successfully merging this pull request may close these issues.

2 participants