[Mono-bugs] [Bug 49011][Min] New - mcs does not report CS0221

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 28 Apr 2004 22:36:27 -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 martin@ximian.com.


--- shadow/49011	2004-04-28 22:36:27.000000000 -0400
+++ shadow/49011.tmp.16439	2004-04-28 22:36:27.000000000 -0400
@@ -0,0 +1,50 @@
+Bug#: 49011
+Product: Mono: Compilers
+Version: unspecified
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Severity: Unknown
+Priority: Minor
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: vargaz@freemail.hu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: V1
+Summary: mcs does not report CS0221
+When compiling the program below, csc (from Net 1.1) reports the
+bug10.cs(3,30): error CS0221: Constant value '-1.#IND' cannot be converted
+to a 'int' (use 'unchecked' syntax to override)
+while mcs compiles it just fine.
+class t {
+        static void Main () {
+                System.Console.WriteLine ((int)double.NaN);
+        }
+------- Additional Comments From miguel@ximian.com  2003-11-27 00:05 -------
+I found that CSC allows values up to 2047 to be cast into a byte, any
+values bigger than that are flagged as an error, ie:
+const double d = 2047;
+byte b = (byte) b;
+I do not understand exactly the nature of the problem yet (when is a
+cast of a constant allowed in this case, and when not). 
+If this is a bug in CSC, the fix is very simple, the code lives in
+Mono.CSharp.Cast.TryReduce () (defined in expression.cs) and we just
+need to repeat the pattern for double and float that we do for the
+other integral types.