digitalmars.D.bugs - [Bug 160] New: static if short-circuit && doesn't work for template arguments
- d-bugmail puremagic.com (31/31) May 29 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=160
- Thomas Kuehne (13/31) Jun 01 2006 -----BEGIN PGP SIGNED MESSAGE-----
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"); --
May 29 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-05-29:http://d.puremagic.com/bugzilla/show_bug.cgi?id=160In 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-----
Jun 01 2006