Skip to content

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

Open
hjmjohnson wants to merge 1 commit into
RTKConsortium:mainfrom
hjmjohnson:fix-conditionalmedian-abs
Open

COMP: Fix ill-formed std::abs<double> in ConditionalMedianImageFilter#975
hjmjohnson wants to merge 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.
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.

1 participant