Bug 5338 – __gshared on class member variable implies static?

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-12-10T01:23:00Z
Last change time
2012-01-20T13:40:39Z
Assigned to
nobody
Creator
braddr

Comments

Comment #0 by braddr — 2010-12-10T01:23:07Z
module buggshared; class A { shared static this() { supported["foo"] = "bar"; } __gshared string[string] supported; } This builds, which means that__gshared in a class scope implies static? That doesn't seem like a good idea. I didn't find where that's documented either.
Comment #1 by hoganmeier — 2011-02-23T02:45:22Z
Makes sense to me. How can a class member be __gshared without being static?
Comment #2 by braddr — 2011-02-23T12:47:31Z
Static means there's a single instance. Shared simply means more than one thread has visibility to it. Two very different properties. Neither implies the other.
Comment #3 by bugzilla — 2012-01-20T13:40:39Z
From attributes.html: "__gshared may also be applied to member variables and local variables. In these cases, __gshared is equivalent to static, except that the variable is shared by all threads rather than being thread local."