www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23391] New: Segmentation fault.

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

          Issue ID: 23391
           Summary: Segmentation fault.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: james.gray remss.net

The following code (reduced by Mayonix on discord) causes the compiler to
crash:
```d
struct MyTuple {
    string s;
}

inout(string) myfront(inout(string)[] a)
{
    return a[0];
}

MyTuple[] myarray(MyZip r)
{
    MyTuple[] result;
    foreach (e; r)
        result ~= e;
    return result;
}

struct MyZip
{
    bool empty = false;
    MyTuple front()
    {
        return MyTuple([""].myfront);
    }
    void popFront()
    {
        empty = true;
    }
}

static foreach(t; MyZip().myarray) {}
```

--
Oct 06 2022