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.
@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
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
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