[Mono-bugs] [Bug 61916][Nor] New - System.InvalidCastException during compile

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 25 Jul 2004 04:35:25 -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 jhr.walter@t-online.de.

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

--- shadow/61916	2004-07-25 04:35:25.000000000 -0400
+++ shadow/61916.tmp.17538	2004-07-25 04:35:25.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 61916
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jhr.walter@t-online.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.InvalidCastException during compile
+
+The following program doesn't compile:
+
+----------
+public class App
+{
+    public static void Main()
+    {
+            for( uint i = uint.MinValue;
+                i < uint.MaxValue - ushort.MaxValue;
+                i += ushort.MaxValue );
+            // for( uint i = uint.MinValue;
+            //     i < uint.MaxValue - (uint) ushort.MaxValue;
+            //     i += (uint) ushort.MaxValue );
+    }
+}
+----------
+
+The compiler diagnoses:
+
+----------
+Exception caught by the compiler while compiling:
+   Block that caused the problem begin at: bug1.cs: (3)
+                     Block being compiled: [Internal: (1),Internal: (1)]
+System.InvalidCastException: Cannot cast from source type to destination 
+type.
+	in ConstantFold.BinaryFold (Mono.CSharp.EmitContext, 
+Mono.CSharp.Binary+Operator, Mono.CSharp.Constant, Mono.CSharp.Constant, 
+Mono.CSharp.Location)
+	in Binary.DoResolve (Mono.CSharp.EmitContext)
+	in Expression.Resolve (Mono.CSharp.EmitContext, 
+Mono.CSharp.ResolveFlags)
+	in Expression.Resolve (Mono.CSharp.EmitContext)
+	in Binary.DoResolve (Mono.CSharp.EmitContext)
+	in Expression.Resolve (Mono.CSharp.EmitContext, 
+Mono.CSharp.ResolveFlags)
+	in Expression.Resolve (Mono.CSharp.EmitContext)
+	in Expression.ResolveBoolean (Mono.CSharp.EmitContext, 
+Mono.CSharp.Expression, Mono.CSharp.Location)
+	in For.Resolve (Mono.CSharp.EmitContext)
+	in Block.Resolve (Mono.CSharp.EmitContext)
+	in Block.Resolve (Mono.CSharp.EmitContext)
+	in EmitContext.EmitTopBlock (Mono.CSharp.Block, 
+Mono.CSharp.InternalParameters, Mono.CSharp.Location)
+----------
+
+Using explicit casts the compiler accepts the code (see the commented 
+lines).