From 8d7de971ef373158b4b77d91aebb5a51aae2281c Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Thu, 26 Nov 2026 10:52:40 -0600 Subject: [PATCH] BUG: Return RieszRotationMatrix tolerance as RealType, not a temporary GetMaxAbsoluteDifferenceCloseToZero() returned const ValueType & (std::complex) for a RealType (double) member, so it bound the reference to a converted temporary and returned it dangling. Clang reports -Wreturn-stack-address: itkRieszRotationMatrix.h:199:12: warning: returning reference to local temporary object Return const RealType &, the type the member and the setter use, and check the round trip in itkRieszRotationMatrixTest. --- .../IsotropicWavelets/include/itkRieszRotationMatrix.h | 2 +- .../IsotropicWavelets/test/itkRieszRotationMatrixTest.cxx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Modules/Filtering/IsotropicWavelets/include/itkRieszRotationMatrix.h b/Modules/Filtering/IsotropicWavelets/include/itkRieszRotationMatrix.h index 06861589993..d3be9fd7204 100644 --- a/Modules/Filtering/IsotropicWavelets/include/itkRieszRotationMatrix.h +++ b/Modules/Filtering/IsotropicWavelets/include/itkRieszRotationMatrix.h @@ -193,7 +193,7 @@ class RieszRotationMatrix : public itk::VariableSizeMatrix> * * \sa itk::Math::FloatAlmostEqual */ - const ValueType & + const RealType & GetMaxAbsoluteDifferenceCloseToZero() const { return this->m_MaxAbsoluteDifferenceCloseToZero; diff --git a/Modules/Filtering/IsotropicWavelets/test/itkRieszRotationMatrixTest.cxx b/Modules/Filtering/IsotropicWavelets/test/itkRieszRotationMatrixTest.cxx index 7b53fd75d73..9efde086dca 100644 --- a/Modules/Filtering/IsotropicWavelets/test/itkRieszRotationMatrixTest.cxx +++ b/Modules/Filtering/IsotropicWavelets/test/itkRieszRotationMatrixTest.cxx @@ -273,6 +273,13 @@ runRieszRotationMatrixTest() constexpr unsigned int order1 = 1; Sdefault.SetOrder(order1); Sdefault.SetSpatialRotationMatrix(R); + constexpr double maxAbsoluteDifference = 1e-5; + Sdefault.SetMaxAbsoluteDifferenceCloseToZero(maxAbsoluteDifference); + if (Sdefault.GetMaxAbsoluteDifferenceCloseToZero() != maxAbsoluteDifference) + { + testPassed = false; + std::cerr << "GetMaxAbsoluteDifferenceCloseToZero() != " << maxAbsoluteDifference << std::endl; + } // compute SteerableMatrix S(R, order1); // copy