D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6726 - DMD crash with index in foreach statement
Summary: DMD crash with index in foreach statement
Status: RESOLVED DUPLICATE of issue 6723
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-24 16:46 UTC by Andrej Mitrovic
Modified: 2011-09-24 16:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-09-24 16:46:02 UTC
Heavily reduced test-case (so the snippet might not make sense), originally from CairoD:

struct ItemRange
{
    @property int front() { return 0; }
}

void main()
{
    ItemRange range;
    foreach (index, element; range)
    {
    }    
}

---------------------------
dmd.exe - Application Error
---------------------------
The instruction at "0x0045b065" referenced memory at "0x00000010". The memory could not be "read".


Click on OK to terminate the program
Click on CANCEL to debug the program
---------------------------
OK   Cancel   
---------------------------

Using DMD 2.055 on XP32. 
Removing index from foreach prevents the crash:

foreach (element; range) { }
Comment 1 Andrej Mitrovic 2011-09-24 16:55:14 UTC

*** This issue has been marked as a duplicate of issue 6723 ***