Thread overview
[Issue 21390] Cannot declare extern (storage class) variable of type with disabled default construction
Feb 28, 2022
Dlang Bot
Feb 28, 2022
Nicholas Wilson
Feb 28, 2022
Dlang Bot
February 28, 2022
https://issues.dlang.org/show_bug.cgi?id=21390

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

--
February 28, 2022
https://issues.dlang.org/show_bug.cgi?id=21390

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m
         Resolution|---                         |WORKSFORME

--- Comment #2 from Nicholas Wilson <iamthewilsonator@hotmail.com> ---
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

--
February 28, 2022
https://issues.dlang.org/show_bug.cgi?id=21390

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--