May 29, 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@digitalmars.com
        ReportedBy: clugdbug@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");


-- 

June 01, 2006
d-bugmail@puremagic.com schrieb am 2006-05-29:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=160

> 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");

Added to DStress as http://dstress.kuehne.cn/run/o/opAndAnd_02_A.d http://dstress.kuehne.cn/run/o/opAndAnd_02_B.d http://dstress.kuehne.cn/run/o/opAndAnd_02_C.d

Thomas