[Bug 160] New: static if short-circuit && doesn't work for template arguments
Thomas Kuehne
thomas-dloop at kuehne.cn
Thu Jun 1 10:57:28 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail at 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
-----BEGIN PGP SIGNATURE-----
iD8DBQFEftC43w+/yD4P9tIRAh1+AJ48/1RxYWPDDOT8fVJC7JcoJucqYgCgmcNI
28ZqwqdwCCEoMMIYc8QBITo=
=cg/e
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list