below lines crash dmd 1.046/2.031 on linux and window platfrom: void func (void delegate () callback) { callback(); } void main () { func(() { asm{ int 3; }; }); }
Reduced test case: void delegate () foo = (){ asm{ int 3; }}; This is segfaulting in iasm.c (line 4269 in DMD2). if( sc->func->type->nextOf()->isScalar()) // segfaults here: nextOf() is null.
This patch is enough to fix the segfault, and allow the code to compile. I'm not sure if it's correct that nextOf() is null, though -- there may be a deeper problem here. iasm.c line 4269. (in Statement *AsmStatement::semantic(Scope *sc)): asmstate.bReturnax = 1; - if (sc->func->type->nextOf()->isscalar()) + if (sc->func->type->nextOf() && sc->func->type->nextOf()->isscalar()) asmstate.bReturnax = 0;
For inferring function return type, the nextOf() is null. That would be a problem here, but we never use bReturnax anyway, so just #if out the code.
(In reply to comment #3) > For inferring function return type, the nextOf() is null. It'd be great if you could put that in a comment in the definition of nextOf(). I'd never been sure when it's supposed to be non-null, it's one of the least obvious things in the code. Should it become non-null in a later semantic pass? Also a comment about the cto, ito, sto members of type would be really useful. When should they be non-null? In a great many of the compiler bugs I've looked at, they're null, but I've not been sure whether the bug is that they're null, or that other code is not dealing with the case that they're null.
Fixed dmd 1.047 and 2.032
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル