immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.91k stars 229 forks source link

Use of `__cdecl` in higher-order contexts casuses panic #904

Open TDecking opened 1 year ago

TDecking commented 1 year ago

The following snippet causes a panic:

void __cdecl free(void*);

void apply(void* ptr, void (*f)(void *));

void crash(void* ptr) {
    apply(ptr, free);
}

The panic can also be triggered using __attribute__((cdecl)), __stdcall, or any other calling convention.