Remove copy/assign/move tests in testAttributes() #1922
Merged
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.
When we implemented the "rule of 5" (PR #601) in 2019, I added code to testAttributes.cpp to validate the behavior, specifically related to the TypedAttribute class, but in retrospect, this code isn't reliable, so I propose eliminating the test altogether.
The test counts invocations of the various constructors, destructors, and move/assignment operators, expecting them to be consistent, but compilers can optionally optimize some of these operations away, producing inconsistent results.
In particular, a Debug build on Windows produces different results from a Release build. In particular, this code:
invokes the move constructor in debug, but a "Release" build optimizes the object away entirely.
Our CI has not historically tested a Windows Debug build, which explains why we never caught this. The exact behavior may have also changed with C++17. All the more reason to avoid such picky tests.
This does not change the library code, only the tests that I added in #601 in 2019.