http://d.puremagic.com/issues/show_bug.cgi?id=7834
Don <clugd...@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugd...@yahoo.com.au Resolution| |INVALID --- Comment #6 from Don <clugd...@yahoo.com.au> 2012-04-23 03:23:44 PDT --- (In reply to comment #0) > In DMD 2.059beta this code compiles with no warnings or errors: > void main(string[] args) { > uint x; > ubyte y = cast(ubyte)args.length; > ubyte z = x % y; > } > So I'd like code similar to this too to compile with no need of a cast: > void main() { > ulong x; > int y; > int z = x % y; > } These two bits of code aren't analogous. If y was -1, when cast to ulong it becomes 0xFFFF_FFFF_FFFF_FFFF Therefore, x % y could be 0.. ulong.max; there's no way that can fit into an int. The compiler is correct. OTOH if you change int -> uint, it works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------