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
Comment #4 by bugzilla — 2016-05-29T01:29:56Z
Comment #5 by github-bugzilla — 2016-05-29T02:07:45Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/47687ca95af80bc690994491effa18dd7d186034 fix Issue 16035 - Compiler crashes with inout, templates, and recursion https://github.com/dlang/dmd/commit/dd583b32a7dae05ddb465a74df389dc4bdb6010c Merge pull request #5791 from 9rnsr/fix16035 Issue 16035 - Compiler crashes with inout, templates, and recursion
Comment #6 by github-bugzilla — 2016-10-01T11:47:01Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/47687ca95af80bc690994491effa18dd7d186034 fix Issue 16035 - Compiler crashes with inout, templates, and recursion https://github.com/dlang/dmd/commit/dd583b32a7dae05ddb465a74df389dc4bdb6010c Merge pull request #5791 from 9rnsr/fix16035