else not attaching properly to if
nobody
nobody at mailinator.com
Mon Oct 29 07:47:03 PDT 2007
I do not think it should ever be the case that this block:
if(false)
if(true)
{
assert(false);
}
else
{
assert(true);
}
should ever be functionally different from this block:
if(false)
{
if(true)
{
assert(false);
}
}
else
{
assert(true);
}
The compiler agrees with me in this simple case. However, I have
found a spot in my code where the second block results in
correct behaviour and the first block does not. This is surely a
compiler (v1.015) bug? Here is the big picture:
struct S
{
void f()
{
while()
{
foreach()
{
if(...)
{
if(...)
{
}
else
if(...)
{
}
}
else
{
if(...)
{ // need brackets or next else is not attached
if(...)
{
}
}
else
{
if(...)
{
}
else if(...)
{
}
else if(...)
{
}
else if(...)
{
}
}
}
}
}
}
}
More information about the Digitalmars-d-bugs
mailing list