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: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@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: -------

Reply via email to