digitalmars.D.bugs - [Issue 22092] New: [REG2.067] for loop over range with closure loops
- d-bugmail puremagic.com (45/45) Jun 29 2021 https://issues.dlang.org/show_bug.cgi?id=22092
https://issues.dlang.org/show_bug.cgi?id=22092 Issue ID: 22092 Summary: [REG2.067] for loop over range with closure loops infinitely Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: wrong-code Severity: regression Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: dlang-bugzilla thecybershadow.net ///////////////////// test.d ///////////////////// void formatRange(T)(T val) { for (size_t i; !val.empty; val.popFront, i) {} } void fun() {} auto makeRange()() { int pos; struct R { bool empty() { return pos == 3; } void popFront() const { ++pos; version (no_bug) fun(); } } return R(); } void main() { auto r = makeRange; formatRange(r); } ////////////////////////////////////////////////// Note that with -version=no_bug (i.e. adding a call to an empty function), the bug does not manifest. Introduced in https://github.com/dlang/dmd/pull/3956 --
Jun 29 2021