[Mono-list] mono vs mint misbehaviour
Stef Van Dessel
stef@iguana.be
Fri, 5 Apr 2002 00:37:14 +0200
Hi,
I've been writing a small application in C# lately, and I stumbled
upon something strange. I've "reduced" the fault to this:
using System;
namespace whatever
{
class Application
{
static void Main(string[] args) {
long temp = 0x00;
// Console.WriteLine("{0:X}", temp);
// this fails with mono, not with mint
for (int i = 0; i < 2; i++) {
temp += ((long) 0x01 << i);
}
Console.WriteLine("{0:X}", temp);
}
}
}
Output with mint: (good)
[stef@weepee stef]$ mint TestCase3.exe
3
Output with mono: (bad)
[stef@weepee stef]$ mono TestCase3.exe
2
RESULT: 0
It looks like the byte shifting is not happening for whatever reason.
The workaround is to replace:
@@ -14 +14,2 @@
- temp += ((long) 0x01 << i);
+ long t = (long) 0x01 << i;
+ temp += t;
This works with both the jit and the interpreter.
Both these versions also compile fine with csc - A csc compiled
executable also misbehaves on mono and not with mint.
stef