digitalmars.D.bugs - [Issue 956] New: Testing Class Object for null reference causes Access Violation Error
- d-bugmail puremagic.com (30/30) Feb 13 2007 http://d.puremagic.com/issues/show_bug.cgi?id=956
- d-bugmail puremagic.com (9/9) Feb 13 2007 http://d.puremagic.com/issues/show_bug.cgi?id=956
- d-bugmail puremagic.com (7/7) Feb 13 2007 http://d.puremagic.com/issues/show_bug.cgi?id=956
http://d.puremagic.com/issues/show_bug.cgi?id=956
Summary: Testing Class Object for null reference causes Access
Violation Error
Product: D
Version: 1.005
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: hennrich.bloebaum gmx.de
class MyClass
{
}
void main()
{
MyClass[] myArray = null;
MyClass myObject = null;
if(!myArray) { // Ok
}
if(myArray == null) { // Works on dynamic arrays
}
if(!myObject) { // Ok
}
if(myObject == null) { // Error: Access Violation
}
}
--
Feb 13 2007
http://d.puremagic.com/issues/show_bug.cgi?id=956 Not a bug. The form "object == null" gets transformed as object.opEquals(null), and so if the object is actually null already, the invocation of it's opEquals member fails. The documented method of testing for null objects is if (object is null) ... --
Feb 13 2007
http://d.puremagic.com/issues/show_bug.cgi?id=956
torhu yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--
Feb 13 2007









d-bugmail puremagic.com 