[Issue 21390] Cannot declare extern (storage class) variable of type with disabled default construction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 28 00:25:39 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=21390

Nicholas Wilson <iamthewilsonator at hotmail.com> changed:

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

--- Comment #2 from Nicholas Wilson <iamthewilsonator at 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

--


More information about the Digitalmars-d-bugs mailing list