Skip to content

Commit 3387cd2

Browse files
committed
Add comment about memcpy
1 parent da8b157 commit 3387cd2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Objects/obmalloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ _PyObject_MiRealloc(void *ctx, void *ptr, size_t nbytes)
332332
size_t copy_size = (size < nbytes ? size : nbytes);
333333
if (copy_size >= offset) {
334334
for (size_t i = 0; i != offset; i += sizeof(void*)) {
335+
// Use memcpy to avoid strict-aliasing issues. However, we probably
336+
// still have unavoidable strict-aliasing issues with
337+
// _Py_atomic_store_ptr_relaxed here.
335338
void *word;
336339
memcpy(&word, (char*)ptr + i, sizeof(void*));
337340
_Py_atomic_store_ptr_relaxed((void**)((char*)newp + i), word);

0 commit comments

Comments
 (0)