std.parallelism example hangs compiler 2.067.1

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 7 11:37:01 PDT 2015


On 8/7/15 2:19 PM, Jay Norwood wrote:
> This appears to hang up dmd compiler 2.067.1. Changing parallel(s) to s
> works ok. Is this a known problem?
>
> import std.stdio;
> import std.string;
> import std.format;
> import std.range;
> import std.parallelism;
>
> int main(string[] argv)
> {
>
>      string s[100000];
>      foreach (i, ref si ; parallel(s)){
>          si = format("hi:%d",i);
>      }
>
>      foreach (ref rm; s[99000..99010]){
>          writeln(rm);
>      }
>      return 0;
> }
>

When you said "hang up", I didn't understand what you meant.

Now I see, it actually hangs dmd (actually, it's not hung, it is still 
running as far as I can tell).

If I reduce to 10000, it completes the compile with an error.

I think it has to do with parallel(s).

In fact, this code also hangs:

int main(string[] argv)
{
    string s[100000];
    parallel(s);
}

In order to get what you really do want (no hangs, no errors), use this:

parallel(s[])

I'll file a bug on this.

-Steve


More information about the Digitalmars-d-learn mailing list