Thread overview
__gshared on structs
Aug 14, 2010
Simen kjaeraas
Aug 14, 2010
Trass3r
Aug 15, 2010
Simen kjaeraas
Aug 21, 2010
Bernard Helyer
Aug 21, 2010
bearophile
August 14, 2010
__gshared struct foo {
   int n;
}

foo f;

This f is not shared between threads, even though the
__gshared indicates it should be. Why is this not an error?

-- 
Simen
August 14, 2010
I don't think that this syntax is supported at all.
You need to use __gshared with the instance instead:
__gshared foo f;
August 15, 2010
Trass3r <un@known.com> wrote:

> I don't think that this syntax is supported at all.
> You need to use __gshared with the instance instead:
> __gshared foo f;

Hence my asking 'Why is this not an error?'.

However, shared struct foo {} works, so one might
expect symmetry to dictate that __gshared might, too.

-- 
Simen
August 21, 2010
On Sun, 15 Aug 2010 17:15:19 +0200, Simen kjaeraas wrote:
> Hence my asking 'Why is this not an error?'.

Because DMD ignores invalid attributes, and almost never flags them as an error (or even a warning!).

`shared scope immutable import foo;`

FWIW, I disagree with this behaviour -- SDC[1] will warn on no-op attributes.

[1]:http://github.com/bhelyer/SDC
August 21, 2010
Bernard Helyer:
> Because DMD ignores invalid attributes, and almost never flags them as an error (or even a warning!).

Vote this: http://d.puremagic.com/issues/show_bug.cgi?id=3934

Bye,
bearophile