// Code snippets which kill dmd. struct A { const a = B.b; } struct B { const b = A.a; } struct C { const x = C.x; } // Some examples which don't segfault. The compiler reports errors as it should. const x = x; const a = b; const b = a;
Related to issue 713? WFM 1.035 Windows. Has it gone away, or is it platform parity?
(In reply to comment #1) > Related to issue 713? > > WFM 1.035 Windows. Has it gone away, or is it platform parity? > The first example now works, but the second one segfaults: struct C { const x = C.x; } Segfaults on DMD2.028 and 1.042 Windows. I've patched it so that it displays: bug.d(2): Error: variable bug.C.x cannot infer type Patch against DMD2.028 in void VarDeclaration::semantic(Scope *sc). Index: declaration.c =================================================================== --- declaration.c (revision 22) +++ declaration.c (working copy) @@ -688,6 +688,7 @@ if (!type) { inuse++; type = init->inferType(sc); + if (!type) { error("cannot infer type"); return; } inuse--; inferred = 1;
Was fixed in DMD2.030, still segfaults in DMD1.045.
This patch isn't great, but since it's already got a proper fix in D2, it might be OK. Index: mtype.c =================================================================== --- mtype.c (revision 192) +++ mtype.c (working copy) @@ -4313,6 +4313,11 @@ s = s->toAlias(); v = s->isVarDeclaration(); + if (v && v->isConst() && !v->type) { + // BUG 1787. TODO: This isn't the best place for this error message, but it prevents a segfault + error(e->loc, "Cannot infer type of %s", v->toChars()); + return e; + } if (v && v->isConst() && v->type->toBasetype()->ty != Tsarray) { ExpInitializer *ei = v->getExpInitializer();
Fixed dmd 1.049
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル