Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extern(C++) const ref to static array incorrectly adds const to the mangle name #19581

Open
dlangBugzillaToGithub opened this issue Jun 11, 2019 · 2 comments
Labels
Feature:extern (C/C++/Obj-C) interfacing to C, C++, Objective-C code P4 Severity:Enhancement

Comments

@dlangBugzillaToGithub
Copy link

Nicholas Wilson (@thewilsonator) reported this on 2019-06-11T14:04:23Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19953

CC List

  • kinke

Description

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).
@dlangBugzillaToGithub
Copy link
Author

kinke commented on 2019-06-11T16:51:18Z

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

@dlangBugzillaToGithub
Copy link
Author

kinke commented on 2019-06-11T19:18:43Z

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).

@thewilsonator thewilsonator added the Feature:extern (C/C++/Obj-C) interfacing to C, C++, Objective-C code label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:extern (C/C++/Obj-C) interfacing to C, C++, Objective-C code P4 Severity:Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants