Fix issue with temporaries when compiling constexpr expression templates with clang#757
Conversation
mborland
left a comment
There was a problem hiding this comment.
Sorry for the delay on this. Looks good to me! Once the CI cycles I'll get it merged
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #757 +/- ##
=========================================
+ Coverage 96.2% 96.2% +0.1%
=========================================
Files 300 301 +1
Lines 29466 29467 +1
=========================================
+ Hits 28332 28333 +1
Misses 1134 1134
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
I'm excited to try this on some curved domain-space geometrical calculations having dynamic allocation. Thanks for the initialtive and hard work @marcoffee, I know you put a lot of thought and dedication into this. Thanks @jzmaddock and @mborland for assisting on this effort, it was a large scope of changes, considering not only this, but the entire scope of issue(s). |
|
@ckormanyos does the failure with I don't see how this PR would affect that test at all? I ran develop and this PR on an ARM Mac with Clang-Darwin-22 instead of 17 and it was fine. I may just upgrade the version of macOS we are running on top of this PR to see what happens. 17 is pretty old at this point |
|
Ok so we are already running macOS-latest so GHA must just be behind. The same test passed under the same compiler with C++17, and 20, just not 14. Perhaps this is a spurious failure? |
I'm glad to be of help!
I agree, it looks like this test is based on random-generated values without a fixed seed, which means they may fail/succeed depending on the value from |
|
Yeah, I like using fixed seed values exactly for this reason. |
|
The test I'll pin the seed on this one to But I'll note that theses limits need to be hammered. But I don't really have huge interest in this test because its primary use was as a sanity andperformance check. So a fixed seed is fine. Cc: @marcoffee and @mborland |
|
See also #758. It was easy, so I just did it. Merge that thing into your branch. The seeds is/are fixed. Sorry for this sporadic issue. I had not expected that one on a perf test. Cc: @marcoffee and @mborland |
@ckormanyos thanks! I will merge it (to both PRs) as soon as it is merged to develop.
No problem, thanks for the fix! |
|
Looks fine to me, I guess if we wanted to go the whole hog we could use |
Hi @marcoffee, the sporadic problem (statistically uncommon) has been eliminated via the use of fixed random seeding and predictable values in the performance heats. Even though it's unlikely, you'd catch another outlier in a while, you should go ahead and merge develop into your branch. Cc: @mborland and @jzmaddock |
1306fc4 to
3645c30
Compare
|
I have rebased this PR onto develop and kicked off the CI run |
@mborland thanks! |
|
I think it's fine to merge |
|
Thanks again for this! Please rebase your constexpr cpp_int on top of develop since you needed this fix |
Fixed the issue discussed here. Currently, clang is unable to compile constexpr
cpp_ints with expression templates enabled due to the tags being stored as reference inside the expressions. This PR adds a simple fix that prefer copying values to the expression when their type is an empty struct, which is the case for all functions used on expressions.Error reproduction on compiler explorer: https://godbolt.org/z/fn69aGsWs