Bug 16289 – no extern(C++) mangling for size_t/unsigned long parameters

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2016-07-18T12:06:57Z
Last change time
2020-02-21T02:17:22Z
Keywords
C++, mangling
Assigned to
No Owner
Creator
Martin Nowak

Comments

Comment #0 by code — 2016-07-18T12:06:57Z
The C++ mangler conflates mangling for unsigned, unsigned long, and unsigned long long depending on the target architecture. Those are separate manglings in C++, independent of their target size. This leads to several linking problems w/ C++ code, in particular when a size_t parameter is involved. We already have some places in cppmangle where we properly handle Id.__c_long/Id.__c_ulong. This should be extended to size_t parameters in extern(C++) functions. We might also consider to change the size_t declaration to exactly match the C++ definition of the used platform.
Comment #1 by code — 2016-07-18T13:50:33Z
It's possible to use cpp_ulong which get's the correct mangling, but it's fairly unfriendly to use. https://github.com/dlang/druntime/blob/fb0dafb741d33ae030c2e7a96bee2c61aa4d3cb4/src/core/stdc/config.d#L91
Comment #2 by bugzilla — 2017-11-01T08:38:24Z
Sometimes I just make the C++ function `extern "C"` and that works.
Comment #3 by pro.mathias.lang — 2020-02-21T02:17:22Z