Skip to content

Commit a7a65a8

Browse files
authored
[flang] explicitly cast the pointer to void* in std::memcpy calls (NFC) (llvm#129946)
This patch is to add the explicit cast to the first argument of std::memcpy.
1 parent 542d52b commit a7a65a8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

flang-rt/lib/runtime/assign.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,16 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
263263
if (MayAlias(to, from)) {
264264
if (mustDeallocateLHS) {
265265
deferDeallocation = &deferredDeallocStatDesc.descriptor();
266-
std::memcpy(deferDeallocation, &to, to.SizeInBytes());
266+
std::memcpy(
267+
reinterpret_cast<void *>(deferDeallocation), &to, to.SizeInBytes());
267268
to.set_base_addr(nullptr);
268269
} else if (!isSimpleMemmove()) {
269270
// Handle LHS/RHS aliasing by copying RHS into a temp, then
270271
// recursively assigning from that temp.
271272
auto descBytes{from.SizeInBytes()};
272273
StaticDescriptor<maxRank, true, 16> staticDesc;
273274
Descriptor &newFrom{staticDesc.descriptor()};
274-
std::memcpy(&newFrom, &from, descBytes);
275+
std::memcpy(reinterpret_cast<void *>(&newFrom), &from, descBytes);
275276
// Pretend the temporary descriptor is for an ALLOCATABLE
276277
// entity, otherwise, the Deallocate() below will not
277278
// free the descriptor memory.

flang-rt/lib/runtime/descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RT_OFFLOAD_API_GROUP_BEGIN
2626
RT_API_ATTRS Descriptor::Descriptor(const Descriptor &that) { *this = that; }
2727

2828
RT_API_ATTRS Descriptor &Descriptor::operator=(const Descriptor &that) {
29-
std::memcpy(this, &that, that.SizeInBytes());
29+
std::memcpy(reinterpret_cast<void *>(this), &that, that.SizeInBytes());
3030
return *this;
3131
}
3232

0 commit comments

Comments
 (0)