www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21927] New: ICE (illegal instruction) with static foreach

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

          Issue ID: 21927
           Summary: ICE (illegal instruction) with static foreach over
                    empty member template
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

//////////////// test.d ///////////////
struct S
{
    template tpl()
    {
    }

    void fun()
    {
        static foreach (p; this.tpl!())
        {
        }
    }
}
///////////////////////////////////////

Compilation fails with:

be = '.' this.tpl!() at [test.d(9)]
[1]    3724069 illegal hardware instruction (core dumped)  dmd -o- test.d

For whatever reason, the "this." is important.

--
May 18