How does this work ?

Somedude lovelydear at mailmetrash.com
Thu Apr 19 08:16:23 PDT 2012


I'm going through a number of bug reports, trying to reproduce the
problems and see what can be closed easily (i.e non reproduced, correct
behaviour, etc), and I just came accross
http://d.puremagic.com/issues/show_bug.cgi?id=7326 titled
"write interprets enum with byte backing type as a character"

Here is the case description:

import std.stdio;

enum X : byte
{
    Foobar = 65,
}

void main()
{
    X x;
    writeln(x);  // writes 'A'
    writeln(cast(byte)x);  // writes 65
}

----------------

That's it.
When I run this on Win32, I get:
Foo
65

Can anyone explain me if it is the correct behaviour, and if yes, why ?
Thx.



More information about the Digitalmars-d-learn mailing list