diff --git a/mypyc/lib-rt/librt_internal.c b/mypyc/lib-rt/librt_internal.c index 9c57d8bef72c..ddb7e10d4b03 100644 --- a/mypyc/lib-rt/librt_internal.c +++ b/mypyc/lib-rt/librt_internal.c @@ -3,6 +3,7 @@ #define PY_SSIZE_T_CLEAN #include #include +#include #include "CPy.h" #define LIBRT_INTERNAL_MODULE #include "librt_internal.h" @@ -39,13 +40,14 @@ #define _READ(result, data, type) \ do { \ - *(result) = *(type *)(((ReadBufferObject *)data)->ptr); \ + memcpy((void *) result, ((ReadBufferObject *)data)->ptr, sizeof(type)); \ ((ReadBufferObject *)data)->ptr += sizeof(type); \ } while (0) #define _WRITE(data, type, v) \ do { \ - *(type *)(((WriteBufferObject *)data)->ptr) = v; \ + type temp = v; \ + memcpy(((WriteBufferObject *)data)->ptr, (const void *) &temp, sizeof(type)); \ ((WriteBufferObject *)data)->ptr += sizeof(type); \ } while (0)