285 – Struct method null pointer assert has line number of "0"

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 285 - Struct method null pointer assert has line number of "0"
Summary: Struct method null pointer assert has line number of "0"
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic
Depends on:
Blocks:
Reported: 2006年08月12日 17:29 UTC by Jarrett Billingsley
Modified: 2014年02月15日 13:19 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jarrett Billingsley 2006年08月12日 17:29:24 UTC
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.
Comment 1 Thomas Kühne 2006年08月14日 06:50:38 UTC
-----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-----
Comment 2 Stewart Gordon 2006年09月09日 18:27:28 UTC
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.
Comment 3 Walter Bright 2006年09月19日 15:24:52 UTC
Fixed in DMC 0.167.


AltStyle によって変換されたページ (->オリジナル) /