[Issue 21662] New: Extern linkage variables cannot be of types with disabled default construction
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 24 23:08:43 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21662
Issue ID: 21662
Summary: Extern linkage variables cannot be of types with
disabled default construction
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
The real-world place where this got in the way was trying to use `extern(C++)
extern __gshared core.stdcpp.basic_string!char` to refer to a variable of type
std::string defined in a C++ library. The problem is not specific to C++
compatibility however.
Example:
---
struct S { @disable this(); }
extern __gshared S someVal;
void main() {}
---
Error: variable onlineapp.someVal default construction is disabled for type S
Can we fix this by giving `someVal` a void initializer? No.
---
struct S { @disable this(); }
extern __gshared S someVal = void;
void main() {}
---
Error: variable onlineapp.someVal extern symbols cannot have initializers
Changing `void` to `S.init` or removing `__gshared` does not change the error
message.
--
More information about the Digitalmars-d-bugs
mailing list