Workaround gcc 13 -Wdangling-reference warning #28837
Draft
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.
Closes #28835
Reason
Building MOOSE with gcc 13.2.0 gives me dangling reference warnings.
I don't see how this could be an actual dangling reference, and gcc has bug reports specifically related to dangling reference false positives from lambda functions, but the test case in bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111607 doesn't actually trigger my gcc version.
Design
Removing the nice beautiful modern-style
if constexpr
lambda function in a constructor initializer list and replacing it with an ugly 20th-century-style template metafunction silences the warning for me.Impact
This PR fixes a nasty false-positive compiler warning if I'm right, or fixes a serious bug if I'm wrong. Either way it hurts the code aesthetics so I'd like to hope there's a better solution.
git blame
seems to point to @dschwen for the code I'm removing here, so I'm pinging him in case he sees another solution or any non-aesthetic issues with my solution.