D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21390 - Cannot declare extern (storage class) variable of type with disabled default construction
Summary: Cannot declare extern (storage class) variable of type with disabled default ...
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-13 18:59 UTC by Nathan S.
Modified: 2022-02-28 09:44 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2020-11-13 18:59:44 UTC
Cannot have extern (storage class) variable of type with disabled default construction.

---
struct S { @disable this(); }
// Does not compile: "default construction is disabled for type `S`"
extern __gshared S gVariable1;
// Does not compile: "extern symbols cannot have initializers"
extern __gshared S gVariable2 = S.init;
---
Comment 1 Dlang Bot 2022-02-28 00:24:12 UTC
@thewilsonator created dlang/dmd pull request #13733 "Add test case for Issue 21390" mentioning this issue:

- Add test case for Issue 21390

https://github.com/dlang/dmd/pull/13733
Comment 2 Nicholas Wilson 2022-02-28 00:25:39 UTC
struct S { @disable this(); }
// Does not compile: "default construction is disabled for type `S`"
extern __gshared S gVariable1;

Works Yields

Up to      2.063  : Failure with output: onlineapp.d(4): Error: variable onlineapp.gVariable1 initializer required for type S
2.064   to 2.078.1: Failure with output: onlineapp.d(4): Error: variable onlineapp.gVariable1 default construction is disabled for type S
2.079.1 to 2.095.1: Failure with output: onlineapp.d(4): Error: variable `onlineapp.gVariable1` default construction is disabled for type `S`
Since      2.096.1: Success and no output

I'm presuming that 

// Does not compile: "extern symbols cannot have initializers"
extern __gshared S gVariable2 = S.init;

was an attempted workaround, as that will probably be a WONTFIX.
That leaves this as WORKSFORME
Comment 3 Dlang Bot 2022-02-28 09:44:46 UTC
dlang/dmd pull request #13733 "Add test case for Issue 21390" was merged into master:

- 971c532be017a0826a9440923c2457b71b4cf8c6 by Nicholas Wilson:
  Add test case for Issue 21390

https://github.com/dlang/dmd/pull/13733