How to provide this arg or functor for algorithm?

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 17 12:04:33 PDT 2015


On Monday, 17 August 2015 at 16:21:16 UTC, thedeemon wrote:
> On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote:
>> I've just checked with my runtime GC hook. Here the call to 
>> func() allocates 12 bytes via gc_malloc, and it's the same for 
>> a 4-elements array, so it's not for the array itself, it's for 
>> a closure, I think.
>
> Also, compiling with -vgc says nothing, compiler (2.068) seems 
> to miss this allocation.

Thanks for confirming.

It seems to be a known issue that the compiler doesn't recognize 
the @nogc violation by the closure:
https://issues.dlang.org/show_bug.cgi?id=14771

That's not a regression, though. 2.067 rejecting the code has 
something to do with this assert:
https://github.com/D-Programming-Language/phobos/blob/v2.067.1/std/algorithm/iteration.d#L453 (code is the same for 2.068).

I don't know if that assert should trigger a @nogc violation or 
not. But anyway, the real issue is 14771, as far as I can tell.


More information about the Digitalmars-d-learn mailing list