[Issue 22092] New: [REG2.067] for loop over range with closure loops infinitely
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 29 19:38:22 UTC 2021
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 at puremagic.com
Reporter: dlang-bugzilla at 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
--
More information about the Digitalmars-d-bugs
mailing list