www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16107] New: [ICE] - Internal error: backend/cgcod.c 2297

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

          Issue ID: 16107
           Summary: [ICE] - Internal error: backend/cgcod.c 2297
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

The following code, compiled with DMD 2.071.1-b2 crashes the compiler:

===============================================
import std.stdio, std.traits;

struct TreeItemChildren(T){}

struct TreeItemSiblings(T){}

class Foo
{
    enum isStruct = is(typeof(this) == struct);
    static if (isStruct)
        alias TreeItemType = typeof(this)*;
    else
        alias TreeItemType = typeof(this);

    TreeItemSiblings!TreeItemType _siblings;    // remove this decl
    TreeItemChildren!TreeItemType _children;    // or this one      : OK
}

template Bug(T)
{
    bool check()
    {
        bool result;
        import std.meta: aliasSeqOf;
        import std.range: iota;

        foreach(i;  aliasSeqOf!(iota(0, T.tupleof.length)))
        {
            alias MT = typeof(T.tupleof[i]);
            static if (is(MT == struct))
                result |= Bug!MT;   // result = result | ... : OK
            if (result) break;     // remove this line       : OK

        }
        return result;
    }
    enum Bug = check();
}

void main()
{
    assert(!Bug!Foo);
}
May 31 2016