D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1896 - null literal check does not work
Summary: null literal check does not work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
: 6444 (view as issue list)
Depends on:
Blocks:
 
Reported: 2008-03-07 10:51 UTC by Frank Benoit
Modified: 2015-06-09 05:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Frank Benoit 2008-03-07 10:51:23 UTC
DMD 1.028 on linux does not issue an error for class types compared against null literal.
Comment 1 yebblies 2012-01-29 19:56:40 UTC
*** Issue 6444 has been marked as a duplicate of this issue. ***
Comment 2 yebblies 2012-01-29 19:58:12 UTC
Works on current dmd (1.068 & 2.058)

void main()
{
    class C {}
    C c;
    if (c != null) {}
    if (c == null) {}
}

Prints:

testx.d(5): Error: use '!is' instead of '!=' when comparing with null
testx.d(6): Error: use 'is' instead of '==' when comparing with null