Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce 2 tweaks to DeviceVector to improve safety of the class #353

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

mabruzzo
Copy link
Collaborator

@mabruzzo mabruzzo commented Nov 1, 2023

  1. Delete implicitly declared constructors/assignment operations. We could definitely define these, but currently they can lead to dereferencing null pointers or double-freeing pointers

  2. While I was here, I also added an explicit check that the elements of the vector are trivially copyable. This is the formal requirement for being able to copy an object with a variant of memcpy.

1. Delete implicitly declared constructors/assignment operations. We could definitely define these, but currently they can lead to dereferencing null pointers or double-freeing pointers

2. While I was here, I also added an explicit check that the elements of the vector are trivially copyable. This is the formal requirement for being able to copy an object with a variant of memcpy.
@mabruzzo mabruzzo force-pushed the minor-Device-Vector-tweak branch from 72aa119 to 33b031b Compare November 1, 2023 16:20
Copy link
Collaborator

@bcaddy bcaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, always happy to improve the safety of this class given that the whole point of it is a safer and easier device array. Other than the comment on the error message I think this is good to go.

src/utils/DeviceVector.h Outdated Show resolved Hide resolved
src/utils/DeviceVector.h Show resolved Hide resolved
@evaneschneider evaneschneider merged commit 2011738 into cholla-hydro:dev Nov 6, 2023
@mabruzzo mabruzzo deleted the minor-Device-Vector-tweak branch May 20, 2024 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants