dmd 1.046 and 2.031 releases

Walter Bright newshound1 at digitalmars.com
Sun Jul 5 23:35:24 PDT 2009


Derek Parnell wrote:
> One of the very much appreciated updates here is "Implicit integral
> conversions that could result in loss of significant bits are no longer
> allowed.". An excellent enhancement, thank you.

Thank Andrei for that, he was the prime mover behind it.

> 
> But I am confused as this below compiles without complaint...
> -----------
> import std.stdio;
> void main()
> {
>    byte iii;
>    ubyte uuu = 250;
>    iii = uuu;
>    writefln("%s %s", iii, uuu);
> }
> -----------
> 
> Output is ...
> -6 250
> 
> But I expected the compiler to complain that an unsigned value cannot by
> implicitly converted to a signed value as that results in loss of
> *significant* bits.

We tried for a long time to come up with a sensible way to deal with the 
signed/unsigned dichotomy. We finally gave that up as unworkable. 
Instead, we opted for a method of significant bits, *not* how those bits 
are interpreted. -6 and 250 are the same bits in byte and ubyte, the 
difference is interpretation.


More information about the Digitalmars-d-announce mailing list