Bug 160 – static if short-circuit && doesn't work for template arguments
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-29T05:01:00Z
Last change time
2014-02-15T13:19:26Z
Assigned to
bugzilla
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2006-05-29T05:01:56Z
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");