Bug 18716 – type const(char)[] can not be mapped to C++

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-03T18:23:52Z
Last change time
2024-12-13T18:58:10Z
Keywords
ice, pull
Assigned to
No Owner
Creator
Jacob Carlborg
See also
https://issues.dlang.org/show_bug.cgi?id=23971
Moved to GitHub: dmd#19419 →

Comments

Comment #0 by doob — 2018-04-03T18:23:52Z
The following code: extern (C++) void foo(const(char)[]) {} Gives the following error: Error: Internal Compiler Error: type const(char)[] can not be mapped to C++
Comment #1 by doob — 2018-04-03T19:03:15Z
Comment #2 by dlang-bot — 2020-02-23T10:09:57Z
@jacob-carlborg updated dlang/dmd pull request #8120 "Fix issue 18716: type `const(char)[]` can not be mapped to C++" fixing this issue: - Fix issue 18716: type `const(char)[]` can not be mapped to C++ D arrays don't have any corresponding type in C++. Instead we mangle it as a templated struct with the name `__dslice`, i.e. `struct __dslice(T)`, where `T` is the element type of the array. For an array of ints it would be mangled as the following type: `__dslice!int`. https://github.com/dlang/dmd/pull/8120
Comment #3 by nick — 2023-06-24T15:26:30Z
Note that: extern (C) void foo(const(char)[]) {} and `dmd -HC` generates: template<typename T> struct _d_dynamicArray final { size_t length; T *ptr; ... }; ... extern "C" void foo(_d_dynamicArray< const char > __param_0_); So hopefully this could happen for extern(C++) too.
Comment #4 by robert.schadek — 2024-12-13T18:58:10Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19419 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB