Work around weird g++ bug - #4509
Merged
Merged
Conversation
The former code was triggering a -Wfree-nonheap-object for me with g++ 15.2.0, but only with exceptions disabled, only in devel mode, and only with -std=c++20; c++17 and c++23 were both fine with it. Too weird for me to distill, and the replacement code is better anyway.
jwpeterson
approved these changes
Aug 2, 2026
jwpeterson
left a comment
Member
There was a problem hiding this comment.
Small question, but whatever works around the compiler bug is fine with me.
| vars_to_read.clear(); | ||
| vars_to_read.push_back(var_to_read); | ||
| } | ||
| vars_to_read.assign({var_to_read}); |
Member
There was a problem hiding this comment.
Was calling assign() actually necessary to work around the bug or would the (arguably simpler)
vars_to_read = {var_to_read};
have sufficed as well?
Member
Author
There was a problem hiding this comment.
Huh - yes, that works too, as does assign(1, var_to_read). I've no clue why it's just the push_back() that gave me pushback. Irony?
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.
The former code was triggering a -Wfree-nonheap-object for me with g++ 15.2.0, but only with exceptions disabled, only in devel mode, and only with -std=c++20; c++17 and c++23 were both fine with it.
Too weird for me to distill, and the replacement code is better anyway.
This probably has nothing to do with our --disable-exceptions test failures, I just hit it while investigating those.