Thread overview
[Issue 13421] disallow __gshared members without static
Sep 04, 2014
Ketmar Dark
Sep 04, 2014
Ketmar Dark
Sep 04, 2014
Ketmar Dark
Sep 04, 2014
Ketmar Dark
Sep 04, 2014
Marc Schütz
Sep 04, 2014
Ketmar Dark
Dec 17, 2022
Iain Buclaw
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
after some thinking i started to believe that we should make exactly the opposite: warn about 'static __gshared' members. '__gshared' implies "one instance", so 'static __gshared' is excessive and meaningless.

--
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #2 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
Created attachment 1413
  --> https://issues.dlang.org/attachment.cgi?id=1413&action=edit
warns on "static __gshared" variables

something like this, heh

--
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #3 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
Created attachment 1414
  --> https://issues.dlang.org/attachment.cgi?id=1414&action=edit
druntime code cleanup

--
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #4 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
Created attachment 1415
  --> https://issues.dlang.org/attachment.cgi?id=1415&action=edit
phobos code cleanup

--
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #5 from Marc Schütz <schuetzm@gmx.net> ---
`static __gshared` is currently indeed redundant, but my point is that this isn't obvious. I would expect it to work analogously to a shared member: You can have static and non-static ones of those. As I see it, __gshared merely means "make it shared, but don't complain about unsynchronized access".

Therefore I can't agree that it implies "one instance". It's IMO better to make it explicit.

--
September 04, 2014
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #6 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
specs clearly says:

> __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.
http://dlang.org/attribute.html#gshared

so "static __gshared" is a tautology, and i believe that it should be error instead of warning. but error'ing it can break some code, so let's warn for now.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=13421

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=13421

--- Comment #7 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18877

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--