www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 285] New: Struct method null pointer assert has line number of "0"

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=285

           Summary: Struct method null pointer assert has line number of "0"
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jarrett.billingsley gmail.com


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.


-- 
Aug 12 2006
next sibling parent reply kris <foo bar.com> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=285
 
            Summary: Struct method null pointer assert has line number of "0"
            Product: D
            Version: 0.163
           Platform: PC
         OS/Version: Windows
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: jarrett.billingsley gmail.com
 
 
 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.
 
 
Cute and all; but I sure hope such codegen is disabled via a switch such as -release ...
Aug 12 2006
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"kris" <foo bar.com> wrote in message 
news:ebln9m$24kh$1 digitaldaemon.com...

 Cute and all; but I sure hope such codegen is disabled via a switch such 
 as -release ...
Indeed it is, just like array bounds checking and the like. In fact, all it does is insert an implicit "assert(this !is null)", and since it's like any other assert, it compiles out in release mode.
Aug 12 2006
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----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-----
Aug 14 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=285


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |diagnostic





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.


-- 
Sep 09 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=285


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed in DMC 0.167.


-- 
Sep 19 2006