std.variant overloaded operators bug?
0ffh
spam at frankhirsch.net
Tue Oct 16 15:58:57 PDT 2007
Hi!
I declare and initialise two Variants:
Variant va=1;
Variant vb=-2;
This works as expected:
printf("%i\n",va.get!(int));
printf("%i\n",vb.get!(int));
Here be dragons at runtime:
printf("%i\n",(va+vb).get!(int));
-> Error: Variant: attempting to use incompatible types ulong and int
printf("%i\n",(va*vb).get!(int));
-> Error: Variant: attempting to use incompatible types ulong and int
Why the heck "ulong"? Makes no sense to me...
printf("%ul\n",(va+vb).get!(ulong)); // of course this is nonsense for -1
printf("%ul\n",(va*vb).get!(ulong)); // of course this is nonsense for -2
This, erm, "works", but I wouldn't...
printf("%i\n",(va+vb).get!(ulong));
printf("%i\n",(va*vb).get!(ulong));
I made a bug report, I hope I made nothing wrong (first-timer there)...
Regards, Frank
More information about the Digitalmars-d
mailing list