[Mono-bugs] [Bug 33185][Maj] New - Mono runtime doesn't seem to give correct results?

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
2 Nov 2002 18:42:00 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by cshei@indiana.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=33185

--- shadow/33185	Sat Nov  2 13:41:59 2002
+++ shadow/33185.tmp.29526	Sat Nov  2 13:41:59 2002
@@ -0,0 +1,108 @@
+Bug#: 33185
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: XP SP1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: cshei@indiana.edu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono runtime doesn't seem to give correct results?
+
+Description of Problem:
+Using the mono runtime to execute a variation of a sample program given in
+Microsoft's "The IL Assembly Language Programmers' Reference," the correct
+output is not produced.
+
+Steps to reproduce the problem:
+1. Use ilasm.exe to assemble the code in "Additional Information"
+2. Run mono EvenOdd.exe
+
+Actual Results:
+Just writes "10000001 is " to console (without even a newline)
+
+Expected Results:
+Should write "10000001 is odd" to console (with a newline after that)
+
+How often does this happen? 
+Every time
+
+Additional Information:
+Using mono --trace, it seems like it goes for a while then quits before the
+number gets down to 0 (this sample demonstrates mutual recursion and tail
+calls).
+
+IL code that doesn't seem to work with Mono:
+
+.assembly EvenOdd { }
+.class EvenOdd
+{ .method private static bool IsEven(int32 N) il managed
+  { .maxstack   2
+    ldarg.0             // N
+    ldc.i4.0
+    bne.un      NonZero
+    ldc.i4.1
+    ret
+NonZero:
+    ldarg.0
+    ldc.i4.1
+    sub
+    tail.
+    call bool EvenOdd::IsOdd(int32)
+    ret
+  } // end of method `EvenOdd::IsEven'
+
+  .method private static bool IsOdd(int32 N) il managed
+  { .maxstack   2
+    // Demonstrates use of argument names and labels
+    // Notice that the assembler does not covert these 
+    // automatically to their short versions
+    ldarg       N
+    ldc.i4.0
+    bne.un      NonZero
+    ldc.i4.0
+    ret
+NonZero:
+    ldarg       N
+    ldc.i4.1
+    sub
+    tail.
+    call bool EvenOdd::IsEven(int32)
+    ret
+  } // end of method `EvenOdd::IsOdd'
+
+  .method public static void Test(int32 N) il managed
+  { .maxstack   1
+    ldarg       N
+    call        void [mscorlib]System.Console::Write(int32)
+    ldstr       " is "
+    call        void [mscorlib]System.Console::Write(class System.String)
+    ldarg       N
+    call        bool EvenOdd::IsEven(int32)
+    brfalse     LoadOdd
+    ldstr       "even"
+Print:
+    call        void [mscorlib]System.Console::WriteLine(class System.String)
+    ret
+LoadOdd:
+    ldstr       "odd"
+    br          Print
+  } // end of method `EvenOdd::Test'  
+} // end of class `EvenOdd'
+
+//Global method
+
+.method public static void main() il managed
+{ .entrypoint
+  .maxstack     1
+  ldc.i4        10000001
+  call          void EvenOdd::Test(int32)
+  ret
+} // end of global method `main'