D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21662 - Extern linkage variables cannot be of types with disabled default construction
Summary: Extern linkage variables cannot be of types with disabled default construction
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-02-24 23:08 UTC by Nathan S.
Modified: 2021-02-27 16:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2021-02-24 23:08:43 UTC
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 Dlang Bot 2021-02-24 23:37:28 UTC
@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 Dlang Bot 2021-02-25 00:35:45 UTC
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 Dlang Bot 2021-02-27 16:56:37 UTC
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