[Issue 20900] New: dmd crashes on static foreach over infinite range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 6 18:17:11 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20900

          Issue ID: 20900
           Summary: dmd crashes on static foreach over infinite range
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: qs.il.paperinik at gmail.com

A quick and easy way to trigger the OutOfMemoryError

struct SimpleRange
{
    this(int front) { this.front = front; }

    bool empty = false;
    int front;
    void popFront() { }
}

void main()
{
    static foreach (x; SimpleRange(1)) { }
}

While it is somewhat obvious that it cannot work, the compiler tells me,
there's a bug in the compiler (
> ERROR: This is a compiler bug.
> Please report it via https://issues.dlang.org/enter_bug.cgi
). And in some way there is. The compiler cannot know that the range is
infinite, but it can just abort at some point.

--


More information about the Digitalmars-d-bugs mailing list