Bug 12350 – Assigning __traits(getAttributes) to variable crashes DMD
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-12T02:48:00Z
Last change time
2014-03-13T16:26:33Z
Keywords
ice, pull
Assigned to
nobody
Creator
tomer
Comments
Comment #0 by tomer — 2014-03-12T02:48:55Z
DMD hangs forever when compiling this code (I have to kill it with a signal)
```
enum MyUDC;
struct MyStruct {
int a;
@MyUDC int b;
}
void testAttrs(T)(const ref T strct) if (is(T == struct)) {
foreach(name; __traits(allMembers, T)) {
// this works
enum index = staticIndexOf!(MyUDC, __traits(getAttributes, __traits(getMember, strct, name)));
// this works
auto tr = __traits(getAttributes, __traits(getMember, strct, name)).stringof;
// this crashes DMD 2.065
auto tr = __traits(getAttributes, __traits(getMember, strct, name));
// as well as this
enum tr = __traits(getAttributes, __traits(getMember, strct, name));
enum index = staticIndexOf!(MyUDC, tr);
}
}
void main() {
MyStruct s;
testAttrs(s);
}
```