Bug 11885 – ICE(s2ir.c 359) with continuing a labeled ByLine (range struct w/ dtor) loop
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-09T03:52:00Z
Last change time
2014-04-11T01:41:42Z
Keywords
ice, pull
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2014-01-09T03:52:38Z
Simple test case:
////////////////////////////////////////////////////////////
import std.stdio;
void main()
{
File f;
l:
foreach (i; f.byLine)
continue l;
}
////////////////////////////////////////////////////////////
Reduced test case:
////////////////////////////////////////////////////////////
struct ByLine
{
@property empty() { return false; }
char[] front() { return null; }
void popFront() { }
~this() { }
}
void main()
{
l:
foreach (i; ByLine())
continue l;
}
////////////////////////////////////////////////////////////
Although in the test cases the struct is a temporary, it doesn't matter - DMD ICEs even if it's a global.
Comment #1 by yebblies — 2014-02-06T22:49:28Z
Reduced:
void main()
{
l:
for (auto x = ByLine();;)
continue l;
}
Which gets transformed to this:
void main()
{
l:
{
ByLine x = ByLine();
try
{
for (;;)
{
continue l;
}
}
finally
{
x.~this();
}
}
return 0;
}
And now the l: is not on the for loop any more.