Why does this not work?

Shachar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 17 05:06:58 PDT 2014


void func( int c )
{
     ubyte a;

     a = cast(ubyte)c + cast(ubyte)c;
}

dmd v2.065 complains about:
test.d(5): Error: cannot implicitly convert expression 
(cast(int)cast(ubyte)c + cast(int)cast(ubyte)c) of type int to 
ubyte

As far as I can tell, adding two values of the same type should 
result in the same type.

Shachar


More information about the Digitalmars-d-learn mailing list