[Issue 3243] instantiated 'static this()' bring on a compiler message ': __gate is thread local'
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 10 18:47:32 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=3243
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|patch |diagnostic
Status|RESOLVED |REOPENED
Resolution|INVALID |---
Summary|Mixin 'static this()' bring |instantiated 'static
|on a compiler message ': |this()' bring on a compiler
|__gate is thread local' |message ': __gate is thread
| |local'
--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to David Nadlinger from comment #4)
> This is indeed an invalid bug as far as D2 is concerned, because the static
> constructor is run once per thread and needs a gate variable to prevent
> being run multiple times in the face of separate compilation. I suppose we
> could improve the diagnostic message, though?
The original issue, the mixed-in `static this()` will report ': __gate is
thread local' message with -vtls, is properly fixed from 2.065, by the
side-effect of the commit:
https://github.com/D-Programming-Language/dmd/commit/9f9e4690d6abcfee5858f48a7eb80d1b7eca5a06
Because the mixin is not a proper template instance, the instantiated code is
inserted in the enclosing scope, so the generated `static this()` will be a
non-instantiated function and should not have gate.
But, if the template is properly instantiated, the static this() still needs
TLS __gate variable implicitly as you said, and it will be listed by -vtls. For
example:
template T()
{
static this() {}
}
class C
{
alias ti = T!();
}
With 2.068.0,
dmd -c -vtls test.d
Will show:
: __gate is thread local
I think this is a minor diagnostic issue. -vlts does not have to list the
internal generated variables like __gate, because it's just confusing.
I change the title and reopen.
--
More information about the Digitalmars-d-bugs
mailing list