Bug 22014 – Wrong MSVC++ mangling of wchar_t

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2021-06-10T15:17:35Z
Last change time
2024-12-13T19:16:58Z
Keywords
pull
Assigned to
No Owner
Creator
kinke
Moved to GitHub: dmd#19944 →

Comments

Comment #0 by kinke — 2021-06-10T15:17:35Z
C++: ``` #include <windows.h> void wchar_test(wchar_t bla) {} void wstr_test(LPCWSTR str) {} ``` => (https://cpp.godbolt.org/z/qGo3roaqh) ?wchar_test@@YAX_W@Z ?wstr_test@@YAXPEB_W@Z The frontend as of 2.097.0 mangles it as (https://d.godbolt.org/z/vhb96c1j3): ?wchar_test@@YAX_S@Z ?wstr_test@@YAXPEB_S@Z The bug is https://github.com/dlang/dmd/blob/a9efb98285713dac64a35e9eb166119d33d5fdc2/src/dmd/cppmanglewin.d#L248.
Comment #1 by dlang-bot — 2022-01-17T10:28:30Z
@RazvanN7 created dlang/dmd pull request #13540 "Fix Issue 22014 - Wrong MSVC++ mangling of wchar_t" fixing this issue: - Fix Issue 22014 - Wrong MSVC++ mangling of wchar_t https://github.com/dlang/dmd/pull/13540
Comment #2 by elpenguino+D — 2023-12-15T05:25:00Z
this appears to be caused by dmd not recognizing wchar_t and instead mangling it as the wchar/dchar it is aliased to. from what I gather, this was intended to be fixed by an abandoned plan for 2.085.0/2.086.0 (https://github.com/dlang/dmd/pull/9029, https://github.com/dlang/dmd/pull/9130, https://github.com/dlang/druntime/pull/2390) that never came to fruition, despite its inclusion in the 2.085.0 changelog. similarly, the related -extern-std switch support never materialized... The mangler does recognize a __c_wchar_t type, but that isn't documented or defined anywhere in dmd and requires a definition similar to `enum __c_wchar_t : wchar` or dchar in user code. unfortunately, core.stdcpp.string's basic_string won't work with this, causing std::wstring support to be just out of reach
Comment #3 by kinke — 2023-12-16T09:55:50Z
(In reply to elpenguino+D from comment #2) > The mangler does recognize a __c_wchar_t type, but that isn't documented or > defined anywhere in dmd and requires a definition similar to `enum > __c_wchar_t : wchar` or dchar in user code. unfortunately, > core.stdcpp.string's basic_string won't work with this, causing std::wstring > support to be just out of reach The magic `__c_wchar_t` enum could be put into core.stdcpp.config like the others, and then (existing) alias `core.stdc.stddef.wchar_t` could alias to it. Wouldn't that suffice?
Comment #4 by kinke — 2023-12-16T09:59:21Z
(In reply to kinke from comment #3) > could be put into core.stdcpp.config like the others Erm, `core.stdc.config`.
Comment #5 by dlang-bot — 2023-12-16T10:24:11Z
@kinke created dlang/dmd pull request #15916 "Fix Issue 22014 - Make core.stdc.stddef.wchar_t match C++ mangling" fixing this issue: - Fix Issue 22014 - Make core.stdc.stddef.wchar_t match C++ mangling https://github.com/dlang/dmd/pull/15916
Comment #6 by robert.schadek — 2024-12-13T19:16:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19944 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB