[Mono-bugs] [Bug 58475][Wis] New - C# miscompiles boolean expression
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 13 May 2004 19:14:43 -0400 (EDT)
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 s001@hotbox.ru.
http://bugzilla.ximian.com/show_bug.cgi?id=58475
--- shadow/58475 2004-05-13 19:14:43.000000000 -0400
+++ shadow/58475.tmp.31533 2004-05-13 19:14:43.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 58475
+Product: Mono: Compilers
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: x86 linux 2.6.5, gcc 3.3.1
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: s001@hotbox.ru
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: C# miscompiles boolean expression
+
+Description of Problem:
+ C# miscompiles boolean expression
+
+Steps to reproduce the problem:
+ Compile and run the following test:
+------------------------------------
+using System;
+
+class App {
+
+ public static long BoolBugTest(long lVal, long rVal)
+ {
+ long rslt = lVal / rVal;
+ long remV = lVal % rVal;
+
+ if (lVal < 0 != rVal < 0)
+ {
+ System.Console.WriteLine("We get here if (lVal < 0 != rVal
+< 0). Lets see:");
+ System.Console.WriteLine(" lVal = " +
+System.Convert.ToString(lVal) +
+ ", rVal = " +
+System.Convert.ToString(rVal));
+ return 1;
+ }
+ return 0;
+ }
+
+ public static int Main(String[] args) {
+ if (BoolBugTest(81,32) == 1)
+ System.Console.WriteLine("Boolean evaluation bug detected.");
+ else
+ System.Console.WriteLine("Test passed OK.");
+ return 0;
+ }
+
+
+}
+
+------------------------------------
+
+Actual Results:
+ Statement in "if (lVal < 0 != rVal < 0)...." is executed.
+
+Expected Results:
+ It shouldn't be!
+
+How often does this happen?
+ Always (for this exact example)