[Issue 6225] New: Some common null test mistakes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 29 17:08:52 PDT 2011
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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list