Scoped in a foreach loop.

Lionello Lunesu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 5 02:06:14 PDT 2015


On 05/06/15 05:07, Yuxuan Shui wrote:
> I tried something like this:
>
> foreach(e; scoped!SomeRangeType(args)) {
> }
>
> And my program segment faults. But this works:
>
> {
>      auto x = scoped!SomeRangeType(args);
>      foreach(e; x) {
>      }
> }
>
> Shouldn't the range be alive until the end of the loop?


Looks like a bug. I can repro it as well.

Filed as https://issues.dlang.org/show_bug.cgi?id=14653

L.


More information about the Digitalmars-d mailing list