[Issue 18991] New: Invalid code in std.iteration.each

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 15 08:18:15 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18991

          Issue ID: 18991
           Summary: Invalid code in std.iteration.each
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: trikkuz at gmail.com

Related to:
https://issues.dlang.org/show_bug.cgi?id=11934

"each" implementation iterate thru ranges using:

foreach(ref x; range) { }

If range hasn't a ref front() this code should throw a compile error (IMO) but
it doesn't.

The worst part is that if x is a struct, ctor is called but dtor is never
called.
In my case if I iterate just a single node of a tree, node dtor is never
called, resources are not freed and in turn the whole tree is never freed (huge
memory leak).

--


More information about the Digitalmars-d-bugs mailing list