Bug 18991 – Invalid code in std.iteration.each

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-15T08:18:15Z
Last change time
2019-10-18T10:43:17Z
Assigned to
No Owner
Creator
Andrea Fontana

Comments

Comment #0 by trikkuz — 2018-06-15T08:18:15Z
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).
Comment #1 by greeenify — 2018-07-17T10:52:20Z