Bug 285 – Struct method null pointer assert has line number of "0"
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-08-12T17:29:00Z
Last change time
2014-02-15T13:19:01Z
Keywords
diagnostic
Assigned to
bugzilla
Creator
jarrett.billingsley
Comments
Comment #0 by jarrett.billingsley — 2006-08-12T17:29:24Z
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 by thomas-dloop — 2006-08-14T06:50:38Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] 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 by smjg — 2006-09-09T18:27:28Z
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.