COMP: Fix GCC -Wmaybe-uninitialized in SymmetricEigenAnalysis column permute#6447
Draft
hjmjohnson wants to merge 1 commit into
Draft
Conversation
…permute GCC 14 emits -Wmaybe-uninitialized warnings (66 instances) that all originate from itk::detail::permuteColumnsWithSortIndices in itkSymmetricEigenAnalysis.h. Assigning a fixed-size Eigen::Matrix in place from a (Matrix * dynamic PermutationMatrix) product leaves GCC's post-inlining analysis of Eigen's vectorized dense-assignment unroll unable to prove every coefficient is written -- a documented Eigen/GCC false positive. Use the Eigen .eval() idiom to materialize the permutation product into a temporary before assignment so the assignment source is a complete object. Column-permutation behavior is unchanged; a full ccache build drops the count 66 -> 0.
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.
GCC 14 emits 66
-Wmaybe-uninitializedwarnings that all originate fromitk::detail::permuteColumnsWithSortIndicesinitkSymmetricEigenAnalysis.h. Forcing the permutation product to materialize with Eigen's.eval()idiom before assignment clears every one of them, with no behavior change.Root cause
The original line assigns a fixed-size matrix in place from a product with a dynamic-size operand:
eigenVectors = eigenVectors * perm; // fixed-size matrix = fixed-size matrix * dynamic PermutationMatrixThe product's source type has dynamic columns. After inlining, GCC's
-Wmaybe-uninitializedanalysis of Eigen's vectorizeddense_assignment_loopunroll cannot prove every coefficient of the fixed-size destination is written, so it flags the inlined SSE load /assign_op::assignCoeffstore. This is a known Eigen/GCC false positive.Why .eval()
.eval()materializes the product into a complete temporary first, so the assignment source is a fully-initialized object and the unroll analysis is satisfied.The idiomatic in-place alternative
eigenVectors.applyOnTheRight(perm)was tried and verified to NOT suppress the warnings — it routes through the same fixed-from-dynamic assignment internally..eval()is the minimal change that actually clears them.Verification (GCC 14.3, full ccache build)
Behavior unchanged (same column permutation); the SymmetricEigenAnalysis and transform tests pass.