[Issue 15505] extern(C++) array parameter mangling gains surprise const
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 11 20:58:37 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=15505
kinke at gmx.net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kinke at gmx.net
--- Comment #4 from kinke at gmx.net ---
(In reply to Manu from comment #0)
> Nobody uses *const in C++.
Don't forget Microsoft; you've already reported a similar MS-specific issue a
while back, with the C++ new operator or some other allocator IIRC.
Well, here we go again:
C++: short test27(int arg[6]); // or `int arg[]`, same thing
Win64: ?test27@@YAFQEAH at Z [short test27(int * const)]
Linux: _Z6test27Pi [test27(int *)]
I don't think this C++ function can be declared directly and portably in D
anyway.
But due to this const-hack, it apparently works in higher dimensions: one can
represent C++ `int p[][6]` as `int[6]* p` in D, and that does indeed work
portably for both MSVC and Itanium.
https://github.com/dlang/dmd/blob/7538ed0125531d3a49ea6d2e266f7bae6e83556f/src/dmd/cppmanglewin.d#L282-L283:
> attention: D int[1][2]* arr mapped to C++ int arr[][2][1]; (because it's more typical situation)
> There is not way to map int C++ (*arr)[2][1] to D
Still, I think that special case is not worth it and more confusing than
useful. It's been there since 2014 or longer:
https://github.com/dlang/dmd/pull/3160
--
More information about the Digitalmars-d-bugs
mailing list