www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16321] New: ICE with delegate in UDA

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

          Issue ID: 16321
           Summary: ICE with delegate in UDA
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ketmar ketmar.no-ip.org

the following code gives
Internal error: backend/cgcod.c 1666
in 2.071 and master:


struct NameAttribute {
  int delegate () foo;
}

static NameAttribute getNamedAttribute(alias S) () {
  NameAttribute res;
  foreach (attr; __traits(getAttributes, S)) {
    static if (is(typeof(attr) == NameAttribute)) res = attr;
  }
  return res;
}

struct MyStruct {
   NameAttribute({ return 42; }) int a;
}

void PrintAll(T) (T arg) {
  foreach (m; __traits(allMembers, T)) {
    enum nameAttr = getNamedAttribute!(__traits(getMember, T, m));
  }
}

void main () {
  PrintAll(MyStruct());
}

--
Jul 25 2016