Is this nogc? dmd and gdc disagree

rcorre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 11 04:55:02 PST 2016


On Thursday, 11 February 2016 at 12:41:16 UTC, rcorre wrote:
> On Thursday, 11 February 2016 at 04:20:13 UTC, tsbockman wrote:
>> Using zip and slices guarantees that the structure returned 
>> will be only 5*size_t.sizeof bytes, regardless of the types of 
>> K and V.
>
> I'm on the DMD 2.070 release, so maybe its fixed in master.
> Either way, thanks for the suggestion!
> Somehow I didn't realize what I was doing was an 
> over-complicated zip :)

Though it appears (in 2.070 at least) that zip's range primitives 
aren't nogc:

---
import std.range;

immutable a = [1,2,3];
immutable b = [1,2,3];

@nogc void main() {
     foreach(x, y ; a[].zip(b[])) { }
}
---
other.d(7): Error: @nogc function 'D main' cannot call non- at nogc 
function 'std.range.Zip!(immutable(int)[], 
immutable(int)[]).Zip.empty'
other.d(7): Error: @nogc function 'D main' cannot call non- at nogc 
function 'std.range.Zip!(immutable(int)[], 
immutable(int)[]).Zip.popFront'
---



More information about the Digitalmars-d-learn mailing list