Bug 9923 – [ICE] (interpret.c line 167) with countUntil on Typedef[]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-04-11T16:03:00Z
Last change time
2013-06-17T17:30:36Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-04-11T16:03:48Z
import std.algorithm: countUntil; import std.typecons: Typedef; alias Foo = Typedef!(const string); immutable Foo[] bar = ["a", "b"]; void main() { Foo a; countUntil(bar, a); } DMD 2.063alpha gives: Assertion failure: 'v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()' on line 167 in file 'interpret.c' Removing the const the compiler doesn't crash: import std.algorithm: countUntil; import std.typecons: Typedef; alias Foo = Typedef!(string); immutable Foo[] bar = ["a", "b"]; void main() { Foo a; countUntil(bar, a); }
Comment #1 by clugdbug — 2013-06-12T23:55:32Z
With latest HEAD, now gives std/typecons.d(3886): Error: cannot modify const expression Typedef_payload walter.d(4): Error: CTFE failed because of previous errors in this There's a bug in Phobos. That type of bug no longer triggers a crash in CTFE.
Comment #2 by bearophile_hugs — 2013-06-13T09:41:03Z
(In reply to comment #1) > There's a bug in Phobos. That type of bug no longer triggers a crash in CTFE. Do you suggest me to open some kind of Phobos bug report?
Comment #3 by andrej.mitrovich — 2013-06-17T16:56:46Z
(In reply to comment #2) > (In reply to comment #1) > > > There's a bug in Phobos. That type of bug no longer triggers a crash in CTFE. > > Do you suggest me to open some kind of Phobos bug report? It looks to me like a compiler bug: ----- struct Typedef(T, T init, string cookie=null) { private T Typedef_payload = init; this(T init) { Typedef_payload = init; // should be allowed AFAIK } mixin Proxy!Typedef_payload; } ----- Try filing it.
Comment #4 by bearophile_hugs — 2013-06-17T17:30:36Z
(In reply to comment #3) > It looks to me like a compiler bug: > > ----- > struct Typedef(T, T init, string cookie=null) > { > private T Typedef_payload = init; > > this(T init) > { > Typedef_payload = init; // should be allowed AFAIK > } > > mixin Proxy!Typedef_payload; > } > ----- > > Try filing it. This code is working: import std.typecons: Proxy; struct Foo(T, T init, string cookie=null) { private T bar = init; this(T init) { bar = init; } mixin Proxy!bar; } void main() { auto f = Foo!(int, 0, "abc")(10); }