DMD 0.148 release

Walter Bright newshound at digitalmars.com
Mon Feb 27 10:21:08 PST 2006


"Thomas Kuehne" <thomas-dloop at kuehne.cn> wrote in message 
news:0fo9d3-mb8.ln1 at birke.kuehne.cn...
> # import std.stdio;
> #
> # int main(){
> # int i = 3;
> # bool a = true;

The next line goes around the type system completely, invalidates any 
invariants on the contents, and so any "surprising" results should be 
unsurprising:

> # bool b = *(cast(bool*)cast(void*) &i);

> #
> # writefln("a: %s", a);
> # writefln("b: %s", b);
> # writefln("int: %s", cast(int)b); // line 9
> # writefln("a+b: %s", a+b); // line 10
> #
> # return 0;
> # }
>
> I know, nobody writes code like that ...
>
> surprise:
> true -> 3 // line 9
> true + true -> 4 // line 10





More information about the Digitalmars-d-announce mailing list