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

Fix warning in some user code when using std::memcpy #6000

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

Rombur
Copy link
Member

@Rombur Rombur commented Mar 20, 2023

This should fix the warning seen by user in #5998

@@ -414,7 +414,7 @@ struct HIPParallelLaunchKernelInvoker<DriverType, LaunchBounds,

// Copy functor (synchronously) to staging buffer in pinned host memory
unsigned long *staging = hip_instance->constantMemHostStaging;
std::memcpy(staging, &driver, sizeof(DriverType));
std::memcpy((void *)staging, (void *)&driver, sizeof(DriverType));
Copy link
Contributor

@nliber nliber Mar 20, 2023

Choose a reason for hiding this comment

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

We should use C++ casts and be const correct (as the C-style cast on &driver isn't, although in this particular case it won't matter, as calling memcpy will put the const back on), as in

std::memcpy(static_cast<void*>(staging), static_cast<const void*>(&driver), sizeof(driver));

@dalg24
Copy link
Member

dalg24 commented Mar 24, 2023

clang-format accident :)

@dalg24 dalg24 merged commit 54da8a2 into kokkos:develop Mar 28, 2023
@dalg24 dalg24 added CHANGELOG Item to be included in release CHANGELOG Patch Release labels Mar 28, 2023
@dalg24
Copy link
Member

dalg24 commented Mar 28, 2023

Please cherry-pick into 4.0.01 patch release

@crtrott
Copy link
Member

crtrott commented Mar 29, 2023

Is this a problem in 3.7? I don't think so or? @Rombur Please cherry-pick to 4.0.01

dalg24 added a commit to dalg24/kokkos that referenced this pull request Mar 29, 2023
Fix warning in some user code when using std::memcpy
@Rombur
Copy link
Member Author

Rombur commented Mar 29, 2023

It's not a problem in 3.7

@Rombur Rombur deleted the fix_memcpy branch March 31, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CHANGELOG Item to be included in release CHANGELOG Patch Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants