Error message for unreachable code
Lionello Lunesu
lio at lunesu.remove.com
Wed Apr 12 00:01:36 PDT 2006
Walter Bright wrote:
> Oskar Linde wrote:
>> I see this as an interesting case of where DMD issues an error for
>> valid code, where a typical C compiler at most would issue a warning.
>> The generated code (with or without const folding) will be correct. I
>> would like to hear why DMD considers the above an error while for
>> instance functions without return values are not.
>
> It comes about from constant folding. It would be difficult for the
> compiler to tell that this code is unreachable.
How come? The compiler clearly knows the bounds of x at the instruction
x[0], so why not constant fold the x.length as well?
L.
More information about the Digitalmars-d
mailing list