Repository navigation
BUG: Return RieszRotationMatrix tolerance as RealType, not a temporary - #7247
Merged
hjmjohnson merged 1 commit intoNov 28, 2026
Merged
hjmjohnson merged 1 commit into
hjmjohnson merged 1 commit into
Conversation
GetMaxAbsoluteDifferenceCloseToZero() returned const ValueType & (std::complex<double>) 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.
dzenanz
approved these changes
Nov 26, 2026
hjmjohnson
marked this pull request as ready for review
November 27, 2026 18:39
Contributor
[Low impact] This PR appears safe to merge.
|
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.
Fix a dangling reference in
RieszRotationMatrix::GetMaxAbsoluteDifferenceCloseToZero(): it returnedconst ValueType &(std::complex<double>) for adoublemember, so the reference bound to a converted temporary. Clang warns-Wreturn-stack-addresson every build of IsotropicWavelets.Merge danger: two-way door; the getter's return type changes from
std::complex<double>todouble, matching the member and the setter. Nothing in ITK or the forest calls it, and its current result is undefined.Shape of the change
itkRieszRotationMatrixTestnow sets the tolerance on its default-constructed matrix and checks the getter returns it.Evidence
Before (Homebrew clang, found while building #7246):
After:
ninja IsotropicWaveletsTestDriver IsotropicWaveletsHeaderTest1builds with 0 errors and no-Wreturn-stack-addresswarning;ctest -R RieszRotationMatrix2/2 pass (itkRieszRotationMatrixTest2D,itkRieszRotationMatrixTest3D).pre-commit run --all-filespasses.Callers searched:
git grep MaxAbsoluteDifferenceCloseToZeroin ITK, and the forest build testbed's repos: none outside the header.AI assistance