Closed
Description
Problem
The 32-bit pointer does not work on platforms other than x64, such as Arm64. See the Godbolt listing.
Sample
#include <cstdint>
int param_std(int* foo) {
int temp = *foo;
*foo = 1;
return temp + sizeof(foo);
}
int param_ptr32(int* __ptr32 __uptr bar) {
int temp = *bar;
*bar = 2;
return temp + sizeof(bar);
}
int emulate_ptr32(uint32_t baz) {
uint64_t baz64 = baz;
int* bazptr = (int*)baz64;
int temp = *bazptr;
*bazptr = 3;
return temp + sizeof(baz);
}
Conclusions
The param_ptr32
disassembler must be equal to emulate_ptr32
, and different from param_std
. Based on the Godbolt listing, the MSVC compiler does just that. But Clang does not take into account the 32-bit pointer under Arm64 (and most likely under other than x64). Its size is 8 bytes, disassembler param_std
and param_ptr32
are the same.