D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19953 - extern(C++) const ref to static array incorrectly adds const to the mangle name
Summary: extern(C++) const ref to static array incorrectly adds const to the mangle name
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-11 14:04 UTC by Nicholas Wilson
Modified: 2024-12-13 19:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nicholas Wilson 2019-06-11 14:04:23 UTC
short test27(int (& const arr)[6][291]) { return 0;};

with MSVC gives warning C4227: anachronism used: qualifiers on reference are ignored

and hence mangles as 

?test27@@YAFAE_A_Y15BCD@H@Z (without the underscores, A being mutable)

whereas DMD mangles

extern(C++) short test27(const ref int[291][6] t);

 as 

?test27@@YAFAE_B_Y15BCD@H@Z (without the underscores, B being const).
Comment 1 kinke 2019-06-11 16:51:18 UTC
The `const` in the D signature doesn't apply to the reference itself, but to the type, i.e., is the same as `ref const(int[291][6])`, and as such your C++ example isn't an analogon.

Proper analogon with a 1D array, showing that the problem goes somewhat deeper:

C++:          short test27(const int (&)[291]);
Win64 mangle: ?test27@@YAFAEAY0BCD@$$CBH@Z

D:            extern(C++) short test27(const ref int[291])
Win64 mangle: ?test27@@YAFAEBY0BCD@H@Z
Comment 2 kinke 2019-06-11 19:18:43 UTC
Related issue for Linux x64:

C++: short test27(const int (&)[6][291])
     _Z6test27RA6_A291_Ki

D:   extern(C++) short test27(ref const int[291][6])
     _Z6test27RKA6_KA291_Ki

Note that the C++ mangling of `const(int[291][6])` and `const(int)[291][6]` is identical for both MSVC and Itanium (and that's fine IMO).
Comment 3 dlangBugzillaToGithub 2024-12-13 19:03:52 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19581

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB