www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18991] New: Invalid code in std.iteration.each


          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 puremagic.com
          Reporter: trikkuz gmail.com

Related to:

"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
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).

Jun 15 2018