Hello, A typo revealed a way to make the compiler segfault. Trying to compile the following incomplete code segment as a complete module causes the official D compiler (versions 1.022 and 2.005) and GDC 0.24 to segfault. //////////// module badcode; void myFunc() { auto func = &NotHere!(1).Bar!(k); // NotHere is not defined. } ///////////// Thanks! --Hoyt
Added to DStress as http://dstress.kuehne.cn/nocompile/t/template_66_A.d http://dstress.kuehne.cn/nocompile/t/template_66_B.d http://dstress.kuehne.cn/nocompile/t/template_66_C.d http://dstress.kuehne.cn/nocompile/t/template_66_D.d http://dstress.kuehne.cn/nocompile/t/template_66_E.d
The segv is in this code: Expression *DotTemplateInstanceExp::semantic(Scope *sc) ... if (!s2) { error("template identifier %s is not a member of %s %s", id->toChars(), s->kind(), s->ident ? s->ident->toChars() : "(null)"); goto Lerr; } ... s->ident is null, so s->ident->toChars() is invalid. I added the ?: expression to validate that, and here's the resulting error message: /home/braddr/sandbox/d/bugs/bug1586.d:5: template instance identifier 'NotHere' is not defined /home/braddr/sandbox/d/bugs/bug1586.d:5: Error: template identifier Bar is not a member of template instance (null) My fix is wrong, but hopefully this will save Walter a few minutes of narrowing down.
While I enjoy another fix: if (!s2) { if(s->ident) error("template identifier %s is not a member of %s %s", id->toChars(), s->kind(), s->ident->toChars() : "(null)"); goto Lerr; } Since the Template Instance is unknown so this error message is useless.
Fixed in DMD2.028; not yet in D1.
Fixed DMD2.028 and 1.045.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル