Thread overview
[Issue 5338] New: __gshared on class member variable implies static?
Dec 10, 2010
Brad Roberts
Feb 23, 2011
Trass3r
Feb 23, 2011
Brad Roberts
Jan 20, 2012
Walter Bright
December 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5338

           Summary: __gshared on class member variable implies static?
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: braddr@puremagic.com


--- Comment #0 from Brad Roberts <braddr@puremagic.com> 2010-12-10 01:23:07 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5338


Trass3r <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool@gmx.de


--- Comment #1 from Trass3r <mrmocool@gmx.de> 2011-02-23 02:45:22 PST ---
Makes sense to me.
How can a class member be __gshared without being static?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5338



--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2011-02-23 12:47:31 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5338


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-20 13:40:39 PST ---
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."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------