June 30, 2011 [Issue 6225] New: Some common null test mistakes | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6225 Summary: Some common null test mistakes Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-06-29 17:03:56 PDT --- In the following four cases of "if" I think it's better to receive warnings from the compiler, because the code probably contains mistakes (this compiles with no errors on DMD 2.053): struct Foo { int x; bool foo() { return true; } } void main() { Foo* p; int* arr = (new int[5]).ptr; if (p != null || p.x) {} if (p == null && p.foo()) {} if (!p && p.foo()) {} if (arr == null && arr[3]) {} } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation