Thread overview |
---|
February 13, 2007 [Issue 956] New: Testing Class Object for null reference causes Access Violation Error | ||||
---|---|---|---|---|
| ||||
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 } } -- |
February 13, 2007 [Issue 956] Testing Class Object for null reference causes Access Violation Error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=956 ------- Comment #1 from ddparnell@bigpond.com 2007-02-13 08:20 ------- 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) ... -- |
February 13, 2007 [Issue 956] Testing Class Object for null reference causes Access Violation Error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=956 torhu@yahoo.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID -- |
Copyright © 1999-2021 by the D Language Foundation