Weird integral promotion issue (?)
Alex Rønne Petersen
xtzgzorex at gmail.com
Sat May 12 14:08:03 PDT 2012
Hi,
alexrp at alexrp ~/Projects/tests $ dmd test.d
test.d(9): Error: cannot implicitly convert expression (240) of type int
to byte
alexrp at alexrp ~/Projects/tests $ cat test.d
import std.stdio, std.traits;
void foo(T)(T val) if (isIntegral!T)
{
}
void main()
{
foo!byte(0b11110000);
}
Why? I explicitly told the compiler that T == byte. Passing 0b00001111
works perfectly fine.
--
- Alex
More information about the Digitalmars-d-learn
mailing list