[Bug 160] New: static if short-circuit && doesn't work for template arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 29 03:01:57 PDT 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=160

           Summary: static if short-circuit && doesn't work for template
                    arguments
           Product: D
           Version: 0.158
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


In the code below, the second term should not be evaluated at all, since
'bird.length>99' is not true. Currently, short-circuit correctly prevents
'fish!()' from being evaluated, but it still incorrectly tries to evaluate
'bird[95]', so compilation fails. I believe this is a regression (though
possibly not a recent one).

-------

template fish( char s)
{
  const bool fish = true;
}

template dog(char [] bird)
{
        static if (bird.length>99 && fish!( (bird[95])) )
           const int dog = 2;
        else const int dog = 3;
}

const int pig = dog!("a");


-- 




More information about the Digitalmars-d-bugs mailing list