[Mono-bugs] [Bug 46090][Nor] New - Explicit conversion from double to int should throw OverflowException in checked context

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 10 Jul 2003 10:46:48 -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 sestoft@dina.kvl.dk.

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

--- shadow/46090	Thu Jul 10 10:46:48 2003
+++ shadow/46090.tmp.13194	Thu Jul 10 10:46:48 2003
@@ -0,0 +1,60 @@
+Bug#: 46090
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sestoft@dina.kvl.dk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Explicit conversion from double to int should throw OverflowException in checked context
+
+Description of Problem:
+
+Explicit conversion from double to int should throw OverflowException on
+overflow in checked context; it does not.  The expected behaviour is
+described in C# spec version 1.1 section 6.2.1.
+
+Steps to reproduce the problem:
+1. Compile and run this program
+
+using System;
+
+class MyTest {
+  public static void Main(String[] args) {
+    // The explicit conversion (int)d should throw OverflowException:
+    checked {
+      double d = 1E20;
+      int i = (int)d;
+      Console.WriteLine(i);
+    }
+  }
+}
+
+Actual Results:
+
+A fairly random integer.
+
+
+Expected Results:
+
+OverflowException is thrown.
+
+
+How often does this happen? 
+
+Always on mono 0.23 for Debian Linux.
+
+
+Additional Information:
+
+Maybe mcs is in agreement with an earlier version of the C# spec, which has
+changed regarding the behaviour of explicit double->integer conversions  
+--- previously these were not affected by checked/unchecked context.