Spurious compiler warning ?
knommad
spam_D at asylum.id.au
Thu Nov 3 00:47:02 PDT 2011
Hi,
I'm a relative newcomer to D, and am enjoying the experience.
I have a small testcase here that causes what seems to be a spurious warning
from the compiler (resulting code still works, however).
Am I missing something??
import std.stdio;
import std.traits;
enum TestEnum
{
ONE = 1,
TWO = 2,
THREE = 3,
FOUR = 4
}
void main()
{
// Generates warning - works as expected though
foreach( TestEnum member; EnumMembers!TestEnum )
{
if ( member == TestEnum.TWO )
continue;
writeln( "A: ", member );
}
// No warning generated
foreach( TestEnum member; EnumMembers!TestEnum )
{
if ( member == TestEnum.TWO )
continue;
else
writeln( "B: ", member );
}
// No warning generated
auto list = EnumMembers!TestEnum;
foreach( TestEnum member; list )
{
if ( member == TestEnum.TWO )
continue;
writeln( "C: ", member );
}
}
compiled with: dmd -wi -oftest test.d
(dmd version 2.056)
output is as expected:
A: ONE
A: THREE
A: FOUR
B: ONE
B: THREE
B: FOUR
C: ONE
C: THREE
C: FOUR
regards,
ted
--
Money can't buy happiness. But it can buy marshmallows, which are kinda the
same thing.
More information about the Digitalmars-d
mailing list