Skip to content

[clang] 32bit pointer (-fms-extensions __ptr32 __uptr) has no effect in ARM64 #62536

Closed
@d-mozulyov

Description

@d-mozulyov

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions