Is this nogc? dmd and gdc disagree

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 10 19:37:09 PST 2016


On Thursday, 11 February 2016 at 03:09:51 UTC, rcorre wrote:
> GDC claims that byKeyValue() allocates a closure, but DMD is 
> just fine with me calling it @nogc. I'm inclined to agree with 
> GDC here, unless DMD is doing some magic so that actually 
> doesn't allocate a closure.

I cannot reproduce your results. Your example won't compile for 
me with DMD HEAD:

source/app.d(16,14): Error: function app.Enumap!(E, 
int).Enumap.byKeyValue is @nogc yet allocates closures with the GC
source/app.d(17,37):        app.Enumap!(E, 
int).Enumap.byKeyValue.__lambda1 closes over variable this at 
source/app.d(16,14)
source/app.d(26,26): Error: template instance app.Enumap!(E, int) 
error instantiating



More information about the Digitalmars-d-learn mailing list