Bug 16035 – Compiler crashes with inout, templates, and recursion
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-17T15:08:00Z
Last change time
2016-10-01T11:47:01Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
marcioapm
Comments
Comment #0 by marcioapm — 2016-05-17T15:08:13Z
import std.conv;
struct Value {
auto toString() inout {
get!string;
}
T get(T)() {
storage_.a[0].to!T;
}
union Storage {
const(Value)* a;
}
Storage storage_;
}
Comment #1 by marcioapm — 2016-05-17T15:12:56Z
Are there any known workarounds?
Comment #2 by schveiguy — 2016-05-17T15:25:36Z
I think it's an infinite recursion. I don't get any specific errors, just segfault while compiling.
Comment #3 by schveiguy — 2016-05-17T15:36:17Z
It has something to do with inout, not with unions.
Reduced case:
struct Value {
auto toString() inout {
get!string;
}
T get(T)() {
a[0].toString();
}
const(Value)* a;
}
Remove inout, and this fails to compile:
testunion.d(7): Error: mutable method testunion.Value.toString is not callable using a const object
testunion.d(3): Error: template instance testunion.Value.get!string error instantiating