This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Add assignment operator to the TestBar test util class.#185
Draft
hwinkler wants to merge 1 commit intoNVIDIA:mainfrom
Draft
Add assignment operator to the TestBar test util class.#185hwinkler wants to merge 1 commit intoNVIDIA:mainfrom
hwinkler wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
I added a an assignment operator to the class, and I added a field named `magic` that I set to certain value during construction. Only an object that has been constructed is likely to have that magic value properly set. An assignment precondition is that the left-hand side is valid. The assignment operators I added assert that the `magic` member of the lhs has the correct value.
Collaborator
|
Converting to draft to prevent merging since this PR's purpose is to detect errors, not fix them. |
brycelelbach
reviewed
Jan 1, 2021
| // Assignment operator | ||
| __host__ __device__ __forceinline__ TestBar& operator =(const TestBar& that) | ||
| { | ||
| assert (magic == MAGIC); |
Collaborator
There was a problem hiding this comment.
This should probably be something other than assert - in a release build, asserts may be turned off, and we want to catch cases where miscompiles in -O3 lead to missed assignments as well. Perhaps it should use the CUB error reporting machinery.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
n.b. this change to test code introduces a lot of failures in the CUB unit tests.
I'm not submitting those fixes -- I've done a few but not all of them.
This change will identify all places in CUB code that attempts an assignment to uninitialized memory.
See https://github.com/NVlabs/cub/issues/184
Change:
I added a an assignment operator to the class, and I added a field named
magicthat I set to a certain value during construction. Only an object that has been constructed is likely to have that magic value properly set.An assignment precondition is that the left-hand side is valid. The assignment operators I added assert that the
magicmember of the lhs has the correct value.