[Mono-bugs] [Bug 38528][Wis] New - Constant overflow causes exception

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sat, 22 Feb 2003 11:41:20 -0500 (EST)


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 dick@ximian.com.

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

--- shadow/38528	Sat Feb 22 11:41:20 2003
+++ shadow/38528.tmp.30141	Sat Feb 22 11:41:20 2003
@@ -0,0 +1,60 @@
+Bug#: 38528
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dick@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Constant overflow causes exception
+
+public class foo {
+        public const ulong wibble=(ulong)~0L;
+
+        public ulong Wibble()
+        {
+                return(wibble);
+        }
+}
+
+gives this output when compiling:
+
+:; mcs unchecked.cs
+unchecked.cs(3) error CS0221: Constant value `-1' cannot be converted to a
+`ulong' (use `unchecked' syntax to override)
+unchecked.cs(3) error CS0150: A constant value is expected
+unchecked.cs(3) error CS0150: A constant value is expected
+Exception caught by the compiler while compiling:
+   Block that caused the problem begin at: unchecked.cs: (5)
+                     Block being compiled: [unchecked.cs: (6),unchecked.cs:
+(8)]
+
+Unhandled Exception: System.InvalidCastException: Cannot cast from source
+type to destination type
+in <0x0025b> 00 Mono.CSharp.MemberAccess:ResolveMemberAccess
+(Mono.CSharp.EmitContext,Mono.CSharp.Expression,Mono.CSharp.Expression,Mono.CSharp.Location,Mono.CSharp.Expression)
+in <0x00371> 00 Mono.CSharp.SimpleName:SimpleNameResolve
+(Mono.CSharp.EmitContext,Mono.CSharp.Expression,bool)
+in <0x0012b> 00 Mono.CSharp.Expression:Resolve
+(Mono.CSharp.EmitContext,Mono.CSharp.ResolveFlags)
+in <0x00033> 00 Mono.CSharp.Return:Resolve (Mono.CSharp.EmitContext)
+in <0x001e4> 00 Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext)
+in <0x0010b> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x00357> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x004c9> 00 Mono.CSharp.MethodData:Emit
+(Mono.CSharp.TypeContainer,Mono.CSharp.Block,object)
+in <0x00023> 00 Mono.CSharp.Method:Emit (Mono.CSharp.TypeContainer)
+in <0x0015e> 00 Mono.CSharp.TypeContainer:Emit ()
+in <0x004b5> 00 Mono.CSharp.RootContext:EmitCode ()
+in <0x007b5> 00 Mono.CSharp.Driver:MainDriver (string[])
+in <0x0000f> 00 Mono.CSharp.Driver:Main (string[])