September 04, 2015 Arithmetic conversion -- warnings missing? | ||||
---|---|---|---|---|
| ||||
import std.stdio; void main() { short ss = -1; ushort us = 0; int si = -1; uint ui = 0; if (ss < us) writeln("a"); else writeln("b"); if (si < ui) writeln("A"); else writeln("B"); } prints "aB" due to integral promotion and arithmetic conversion rules. I know it's this kind of thing: If it compiles and looks like c, it behaves the same. But why does it compile and why does it so without any warning? Is there any rationale to make this even work? |
Copyright © 1999-2021 by the D Language Foundation