is this intended behavior?

Derek Parnell derek at psych.ward
Mon Apr 9 15:11:28 PDT 2007


On Mon, 09 Apr 2007 15:01:56 -0400, Frank Malone wrote:

> dmd v1.010
> 
> import std.stdio;
> void main() {
>         uint a = 3;
>         ubyte b = 3;
>         int c = -1;
>         writefln(c < a ? "true" : "false"); // outputs false
>         writefln(c < b ? "true" : "false"); // outputs true
> }

Yes, kind of ... it is undefined behaviour ... the compiler doesn't know
what to do so it does something dumb instead. I believe that a warning
(a.k.a "error" in Walter-speak) should be issued by the compiler.

-- 
Derek Parnell
Melbourne, Australia
"Justice for David Hicks!"
skype: derek.j.parnell



More information about the Digitalmars-d mailing list