[Issue 5735] New: struct implicitly converted to boolean.
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Mar 14 11:07:12 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=5735
           Summary: struct implicitly converted to boolean.
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ibuclaw at ubuntu.com
--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2011-03-14 11:04:05 PDT ---
Example code:
struct A {}
void foo(bool cond){}
void main()
{
    A a;
    int i;
    assert(a);      // type A does not have a boolean value
    assert(i || a); // type A does not have a boolean value
    assert(0 || a); // OK
    if(a) {}        // type A does not have a boolean value
    if(i || a) {}   // type A does not have a boolean value
    if(0 || a) {}   // type A does not have a boolean value
    foo(a);         // cannot implicitly convert type A to bool
    foo(i || a);    // OK
    foo(0 || a);    // OK
}
The three examples that pass really should be errors.
Regards
-- 
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