[Mono-bugs] [Bug 74597][Wis] New - bitwise shift on negative values is incorrectly computed
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 13 Apr 2005 17:39:46 -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 nazgul@omega.pl.
http://bugzilla.ximian.com/show_bug.cgi?id=74597
--- shadow/74597 2005-04-13 17:39:46.000000000 -0400
+++ shadow/74597.tmp.31403 2005-04-13 17:39:46.000000000 -0400
@@ -0,0 +1,61 @@
+Bug#: 74597
+Product: Mono: Compilers
+Version: 1.0
+OS:
+OS Details: mono 1.1.6
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: nazgul@omega.pl
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: bitwise shift on negative values is incorrectly computed
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+monsters like (-100) << (-3) are understood wrongly by mcs
+IMHO such things should be forbidded, but C# seems to allow this
+
+Steps to reproduce the problem:
+1. Compile and run:
+
+using System;
+
+class X {
+ static void Main ()
+ {
+ Console.WriteLine ((-100) >> (-3));
+ }
+}
+
+
+Actual Results:
+-1
+
+Expected Results:
+7
+
+How often does this happen?
+Always
+
+Additional Information:
+csc from Beta1 gives 7, which is probably according to
+
+1 For the predefined operators, the number of bits to shift is computed as
+follows:
+
+ * 2 When the type of x is int or uint, the shift count is given by the
+low-order five bits of count. 3 In other words, the shift count is computed
+from count & 0x1F.
+ * 4 When the type of x is long or ulong, the shift count is given by
+the low-order six bits of count. 5 In other words, the shift count is
+computed from count & 0x3F
+
+from
+http://www.jaggersoft.com/csharp_standard/14.8.htm