www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ide - VisualD: Error disabling access to shared memory objects

reply Nuno Leiria <omniparagon hotmail.com> writes:
If I enable "disable access to shared memory objects (DMD 
2.088+)" then this simple example doesn't compile:

void main()
{
     string line;
     while ((line = stdin.readln()) !is null)
         write(line);
}

It fails with the error:

C:\D\dmd-2.094.0\windows\bin\..\..\src\phobos\std\stdio.d-mixin-4874(4874):
Error: direct access to shared `stdin` is not allowed, see `core.atomic`

Can anyone explain why?
Sep 28 2020
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Monday, 28 September 2020 at 22:10:58 UTC, Nuno Leiria wrote:
 If I enable "disable access to shared memory objects (DMD 
 2.088+)" then this simple example doesn't compile:

 void main()
 {
     string line;
     while ((line = stdin.readln()) !is null)
         write(line);
 }

 It fails with the error:

 C:\D\dmd-2.094.0\windows\bin\..\..\src\phobos\std\stdio.d-mixin-4874(4874):
Error: direct access to shared `stdin` is not allowed, see `core.atomic`

 Can anyone explain why?
Well, stdin is shared. And you have said you don't want to allow it.
Sep 29 2020
parent reply Nuno Leiria <omniparagon hotmail.com> writes:
On Tuesday, 29 September 2020 at 22:16:55 UTC, Imperatorn wrote:
 Well, stdin is shared. And you have said you don't want to 
 allow it.
Thanks, can you please point me to a reference where I can learn more this behavior? I couldn't find anything about it. And is there a way to disable access to shared memory objects on a per function basis, rather than everything at once?
Sep 30 2020
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 30 September 2020 at 08:07:52 UTC, Nuno Leiria 
wrote:
 On Tuesday, 29 September 2020 at 22:16:55 UTC, Imperatorn wrote:
 Well, stdin is shared. And you have said you don't want to 
 allow it.
Thanks, can you please point me to a reference where I can learn more this behavior? I couldn't find anything about it. And is there a way to disable access to shared memory objects on a per function basis, rather than everything at once?
https://dlang.org/spec/attribute.html
Oct 04 2020