struct S { void fork() { } } void main() { S* s = null; s.fork(); } This causes an AssertError with the correct module name, but with a line number of 0, which is really, really unhelpful. I didn't know DMD even inserted this null check, I think it's pretty cool :) Would be nice if it included the message "struct 'this' pointer is null" or "struct method called through null pointer" or something along those lines.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail@puremagic.com schrieb am 2006年08月12日: > http://d.puremagic.com/issues/show_bug.cgi?id=285 > struct S > { > void fork() > { > > } > } > > void main() > { > S* s = null; > s.fork(); > } > > This causes an AssertError with the correct module name, but with a line number > of 0, which is really, really unhelpful. Added to DStress as http://dstress.kuehne.cn/norun/s/struct_26_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE311mLK5blCcjpWoRAgLDAJ983i4AEjVnn+emYaqF5M7rNomWnwCdFh8j ZZrKf+r07qwMgzWZMsQVBy4= =GPCO -----END PGP SIGNATURE-----
It's been suggested before that we should have some kind of error that unambiguously indicates an attempt to dereference a null pointer. This was mainly in reference to class object references, but I suppose it would apply to structs just as well.
Fixed in DMC 0.167.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル