[Mono-bugs] [Bug 41345][Nor] New - MCS generates an unhandled InvalidCastException when mixing ref & out specifiers

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 14 Apr 2003 19:03:55 -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 jonpryor@vt.edu.

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

--- shadow/41345	Mon Apr 14 19:03:55 2003
+++ shadow/41345.tmp.3103	Mon Apr 14 19:03:55 2003
@@ -0,0 +1,103 @@
+Bug#: 41345
+Product: Mono/MCS
+Version: unspecified
+OS: Red Hat 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jonpryor@vt.edu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: MCS generates an unhandled InvalidCastException when mixing ref & out specifiers
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+MCS generates an unhandled InvalidCastException when mixing ref & out
+specifiers.  For example, if the function definition specifies that a
+parameter is "out", but "ref" is used in the call site, an
+InvalidCastException is generated.
+
+This exists with 0.23 (CVS).
+
+Steps to reproduce the problem:
+1. Compile the following code:
+
+    class RefOutBug
+    {
+      private static void Foo (out int i)
+      {
+        i = 42;
+      }
+
+      public static void Main ()
+      {
+        int n = 16;
+        Foo (ref n);
+      }
+    }
+
+Actual Results:
+
+Exception caught by the compiler while compiling:
+   Block that caused the problem begin at: ro.cs: (10)
+                     Block being compiled: [ro.cs: (11),ro.cs: (14)]
+
+Unhandled Exception: System.InvalidCastException: Cannot cast from source
+type to destination type
+in <0x00035> 00 System.Text.RegularExpressions.PatternCompiler:BeginLink
+(System.Text.RegularExpressions.LinkRef)
+in <0x00015> 00 System.Text.RegularExpressions.PatternCompiler:EmitAnchor
+(int,System.Text.RegularExpressions.LinkRef)
+in <0x000f1> 00
+System.Text.RegularExpressions.Syntax.RegularExpression:Compile
+(System.Text.RegularExpressions.ICompiler,bool)
+in <0x0012c> 00 System.Text.RegularExpressions.Regex:.ctor
+(string,System.Text.RegularExpressions.RegexOptions)
+in <0x00032> 00 System.Text.RegularExpressions.Regex:Replace
+(string,string,System.Text.RegularExpressions.MatchEvaluator,System.Text.RegularExpressions.RegexOptions)
+in <0x00064> 00 Mono.CSharp.TypeManager:CSharpName (System.Type)
+in <0x00052> 00 Mono.CSharp.Argument:FullDesc (Mono.CSharp.Argument)
+in <0x001a9> 00 Mono.CSharp.Invocation:VerifyArgumentsCompat
+(Mono.CSharp.EmitContext,System.Collections.ArrayList,int,System.Reflection.MethodBase,bool,System.Type,Mono.CSharp.Location)
+in <0x0054b> 00 Mono.CSharp.Invocation:OverloadResolve
+(Mono.CSharp.EmitContext,Mono.CSharp.MethodGroupExpr,System.Collections.ArrayList,Mono.CSharp.Location)
+in <0x00374> 00 Mono.CSharp.Invocation:DoResolve (Mono.CSharp.EmitContext)
+in <0x00151> 00 Mono.CSharp.Expression:Resolve
+(Mono.CSharp.EmitContext,Mono.CSharp.ResolveFlags)
+in <0x0001d> 00 Mono.CSharp.StatementExpression:Resolve
+(Mono.CSharp.EmitContext)
+in <0x0025e> 00 Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext)
+in <0x0011a> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x00366> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x0053a> 00 Mono.CSharp.MethodData:Emit
+(Mono.CSharp.TypeContainer,Mono.CSharp.Block,object)
+in <0x00023> 00 Mono.CSharp.Method:Emit (Mono.CSharp.TypeContainer)
+in <0x00297> 00 Mono.CSharp.TypeContainer:Emit ()
+in <0x004c8> 00 Mono.CSharp.RootContext:EmitCode ()
+in <0x0075d> 00 Mono.CSharp.Driver:MainDriver (string[])
+in <0x0000f> 00 Mono.CSharp.Driver:Main (string[])
+
+Expected Results:
+
+Something similar to CSC.EXE's output:
+
+    ro.cs(13,9): error CS1502: The best overloaded method match for
+'RefOutBug.Foo(out int)' has some invalid arguments
+    ro.cs(13,18): error CS1503: Argument '1': cannot convert from 'ref int'
+to 'out int'
+
+How often does this happen? 
+
+All the time.
+
+Additional Information: