www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15129] New: std.parallelism.parallel doesn't enforce


          Issue ID: 15129
           Summary: std.parallelism.parallel doesn't enforce
           Product: D
           Version: D2
          Hardware: x86_64
               URL: http://forum.dlang.org/post/fprccfrqntxqbsrbrtfh forum
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: schuetzm gmx.net
        Depends on: 1983, 11043

This compiles:

    ulong i = 0;
    foreach (f; parallel(iota(1, 1000000+1)))
        i += f;

The delegate to which the function body is converted has mutable references to
thread-local data, and should therefore be rejected.

If parallel takes its delegate via scope (as it should), and there are no
aliases to the context passed to parallel() (e.g. as a second parameter), it is
sufficient for the context to be const, otherwise it probably needs to be

Sep 30 2015