Bug 21662 – Extern linkage variables cannot be of types with disabled default construction

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-24T23:08:43Z
Last change time
2021-02-27T16:56:37Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2021-02-24T23:08:43Z
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.
Comment #1 by dlang-bot — 2021-02-24T23:37:28Z
@n8sh created dlang/dmd pull request #12231 "Extern linkage variables cannot be of types with disabled default construction" fixing this issue: - Fix Issue 21662 - Extern linkage variables cannot be of types with disabled default construction https://github.com/dlang/dmd/pull/12231
Comment #2 by dlang-bot — 2021-02-25T00:35:45Z
dlang/dmd pull request #12231 "Extern linkage variables cannot be of types with disabled default construction" was merged into stable: - 0d491f0ee055b2a7dbd999b5e835117ae5da5035 by Nathan Sashihara: Fix Issue 21662 - Extern linkage variables cannot be of types with disabled default construction https://github.com/dlang/dmd/pull/12231
Comment #3 by dlang-bot — 2021-02-27T16:56:37Z
dlang/dmd pull request #12238 "merge stable" was merged into master: - 774f2ed263af43bdae5532fce556f71905fd671a by Nathan Sashihara: Fix Issue 21662 - Extern linkage variables cannot be of types with disabled default construction https://github.com/dlang/dmd/pull/12238