using a typedefed variable with library classes
Christopher Wright
dhasenan at gmail.com
Sun Jan 18 06:38:27 PST 2009
Charles Hixson wrote:
> Unfortunately, what it tried to do was cast it to either byte or long
> rather than the base case (which was int). Fortunately it couldn't
> decide which to cast it as, as either choice would have been an error.
> (I'm writing to a binary file, and the size of the item written is
> significant.)
The following works for me (using LDC):
typedef int mint;
void foo (long i) {}
void main ()
{
mint a = 1;
foo (a);
}
However, this also works:
typedef int mint;
void foo (byte i) {}
void main ()
{
mint a = 1;
foo (a);
}
It's an implicit narrowing conversion -- that involves data loss. This
is a bug.
More information about the Digitalmars-d-learn
mailing list