Created attachment 554 [details] patch to convert seg-v to assert I'm getting a seg-v (not an assert) at expression.c:6255 from some bad template code. this is the test case: http://www.dsource.org/projects/scrapple/browser/trunk/units/si2.d?rev=689 compile with "-unittest -version=BUG" to get error compile with "-unittest" to get correct result. attached is a patch that converts the seg-v to an assert.
I forgot to mention; I tried to cut down the test case and it quit erroring.
I can't reproduce the segfault. When compiling si2, I just get this: ------ si2.d(155): Error: Cannot interpret SIB!(__T5BatchVi1Vi1Vi0Vi1Vi0Vi1Vi0Vi1Vi0Vi1 Z,real) at compile time si2.d(155): Error: Cannot interpret SIB!(__T5BatchVi1Vi1Vi0Vi1Vi0Vi1Vi0Vi1Vi0Vi1 Z,real) at compile time si2.d(155): Error: template instance 'Batch!(LengthN,1,MassN,1,TimeN,1,TempN,1,C urrentN,1)' is not a variable si2.d(155): Error: no property 'LenD' for type 'int'
What version of DMD? I got it with 2.039 on both windows and linux. Might it already be fixed in SVN?
(In reply to comment #3) > What version of DMD? I got it with 2.039 on both windows and linux. Might it > already be fixed in SVN? I can reproduce it now. I think I had the wrong rational.d.
Reduced test case. Something to do with opDispatch. ====================== int crayon; struct SIB(alias junk) { template Alike(V) { enum bool Alike = Q == V.garbage; } void opDispatch(string s)() { static assert(Alike!(SIB!(crayon))); } } void main() { SIB!(SIB!(crayon).E)(3.0); }
Cause: If global.errors && !global.gag, TemplateInstance::semantic doesn't set 'inst'. So this is a possible patch (not recommended) inside template.c: { if (!global.gag) { /* Trying to soldier on rarely generates useful messages * at this point. */ fatal(); } + inst = this; // error recovery return; } === But, on the other hand, most other functions in expression.c only run ti->semantic() if there are global.errors. So this patch to expression.c line 6252 may be better: Expression *DotTemplateInstanceExp::semantic(Scope *sc) { #if LOGSEMANTIC printf("DotTemplateInstanceExp::semantic('%s')\n", toChars()); #endif Expression *eleft; Expression *e = new DotIdExp(loc, e1, ti->name); L1: e = e->semantic(sc); if (e->op == TOKdottd) { + if (global.errors) return new ErrorExp(); DotTemplateExp *dte = (DotTemplateExp *)e; TemplateDeclaration *td = dte->td; The same problem occurs in mtype.c, line 6613, 7101, inside ::dotExp(), for structs and classes, and they should probably have the same fix. (they shouldn't be running ti->semantic() if there are global errors).
changeset 367
(In reply to comment #7) > changeset 367 http://www.dsource.org/projects/dmd/changeset/367
Fixed dmd 1.057 and 2.041
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル