[Mono-bugs] [Bug 67042][Nor] New - Compiler crash with static string a; string b = a + "x"

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 29 Sep 2004 00:04:52 -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 jhill@arcfocus.com.


--- shadow/67042	2004-09-29 00:04:52.000000000 -0400
+++ shadow/67042.tmp.31734	2004-09-29 00:04:52.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 67042
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jhill@arcfocus.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Compiler crash with static string a; string b = a + "x"
+Description of Problem:
+The following test case will compile fine on csc, but mcs will fail with an
+InvalidCastException.  If you remove either of the constructors, the
+compilation will succeed.
+Steps to reproduce the problem:
+1.  Create X.cs file with the following code:
+class X {
+  static string a = "static string";
+  string b = a + "string";
+  X () {}
+  X (int x) {}
+  static void Main () {}
+2. Attempt to compile:
+mcs X.cs
+Actual Results:
+Unhandled Exception: System.InvalidCastException: Cannot cast from source
+type to destination type.
+in <0x00070> Mono.CSharp.StringConcat:Emit (Mono.CSharp.EmitContext)
+in <0x000fa> Mono.CSharp.FieldExpr:EmitAssign
+in <0x001c7> Mono.CSharp.Assign:Emit (Mono.CSharp.EmitContext,bool)
+in <0x00012> Mono.CSharp.Assign:EmitStatement (Mono.CSharp.EmitContext)
+in <0x0019b> Mono.CSharp.TypeContainer:EmitFieldInitializers
+in <0x00286> Mono.CSharp.Constructor:Emit ()
+in <0x00344> Mono.CSharp.TypeContainer:EmitType ()
+in <0x005a7> Mono.CSharp.RootContext:EmitCode ()
+in <0x00b7f> Mono.CSharp.Driver:MainDriver (string[])
+in <0x00012> Mono.CSharp.Driver:Main (string[])
+Expected Results:
+Compilation succeeded
+How often does this happen? 
+Additional Information:
+When mcs fails, it will not output a file name or number, making this issue
+difficult to track in larger projects.