Is this nogc? dmd and gdc disagree

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 10 20:20:13 PST 2016


On Thursday, 11 February 2016 at 03:09:51 UTC, rcorre wrote:
> I recently tried compiling enumap with GDC, and found that it 
> disagrees with DMD on whether a function is @nogc. Here's a 
> semi-reduced test-case:

Here's an @nogc version of `byKeyValue()`:

@nogc auto byKeyValue() const {
   static immutable keys = [EnumMembers!K];
   return zip(keys[], _store[]);
}

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.


More information about the Digitalmars-d-learn mailing list