[Mono-bugs] [Bug 35190][Nor] New - Bat string concatenation

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
6 Dec 2002 11:44:50 -0000


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 juancri@tagnet.org.

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

--- shadow/35190	Fri Dec  6 06:44:50 2002
+++ shadow/35190.tmp.15994	Fri Dec  6 06:44:50 2002
@@ -0,0 +1,208 @@
+Bug#: 35190
+Product: Mono/MCS
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: juancri@tagnet.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Bat string concatenation
+
+Description of Problem:
+
+On concatenation of strings and int's, there's a mistake generating the 
+CLI code.
+
+///////////// CODE ////////////
+
+using System;
+
+class Test {
+	public static void Main() {
+		int i = 0;
+		int j = 1;
+		// Test i / 0
+		Console.WriteLine(i + " " + "is the number");
+		Console.WriteLine(0 + " " + "is the number");
+		Console.WriteLine(i + " is the number");
+		Console.WriteLine(0 + " is the number");
+		// Test j / 1
+		Console.WriteLine(j + " " + "is the number");
+		Console.WriteLine(1 + " " + "is the number");
+		Console.WriteLine(j + " is the number");
+		Console.WriteLine(1 + " is the number");
+	}
+}
+
+/////////// END CODE //////////
+
+
+Steps to reproduce the problem:
+1. Compile the attachment with mcs and csc
+2. Run each one
+
+
+
+The code and the output:
+
+
+// Case 1 bad: Console.WriteLine(i + " " + "is the number");
+
+Code (MCS):
+	IL_0004: ldloc.0 
+	IL_0005: box [mscorlib]System.Int32
+	IL_000a: ldstr " "
+	IL_000f: ldstr "is the number"
+	IL_0014: call string valuetype [corlib]System.String::Concat
+(string, string, string)
+
+OUTPUT:
+ is the number
+
+Code (CSC):
+	IL_0004: ldloc.0 
+	IL_0005: box [mscorlib]System.Int32
+	IL_000a: ldstr " is the number"
+	IL_000f: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUTPUT:
+0 is the number
+
+
+// Case 2 bad: Console.WriteLine(0 + " " + "is the number");
+
+Code (MCS):
+	IL_001e: ldc.i4.0 
+	IL_001f: box [mscorlib]System.Int32
+	IL_0024: ldstr " "
+	IL_0029: ldstr "is the number"
+	IL_002e: call string valuetype [corlib]System.String::Concat
+(string, string, string)
+
+OUTPUT:
+ is the number
+
+Code (csc):
+	IL_0019: ldc.i4.0 
+	IL_001a: box [mscorlib]System.Int32
+	IL_001f: ldstr " is the number"
+	IL_0024: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUTPUT:
+0 is the number
+
+
+// Case 3 good!: Console.WriteLine(i + " is the number");
+
+Code (mcs) same as csc:
+	IL_0038: ldloc.0 
+	IL_0039: box [mscorlib]System.Int32
+	IL_003e: ldstr " is the number"
+	IL_0043: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUTPUT:
+0 is the number
+
+
+// Case 4 good!: Console.WriteLine(0 + " is the number");
+
+Code (mcs) same as csc:
+	IL_004d: ldc.i4.0 
+	IL_004e: box [mscorlib]System.Int32
+	IL_0053: ldstr " is the number"
+	IL_0058: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUTPUT:
+0 is the number
+
+
+// Case 5 diferent: Console.WriteLine(j + " " + "is the number");
+
+Code (mcs):
+	IL_0062: ldloc.1 
+	IL_0063: box [mscorlib]System.Int32
+	IL_0068: ldstr " "
+	IL_006d: ldstr "is the number"
+	IL_0072: call string valuetype [corlib]System.String::Concat
+(string, string, string)
+
+OUTPUT:
+1 is the number
+
+Code (csc):
+	IL_0058: ldloc.1 
+	IL_0059: box [mscorlib]System.Int32
+	IL_005e: ldstr " is the number"
+	IL_0063: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUPUT:
+1 is the number
+
+// Case 6 bad: Console.WriteLine(1 + " " + "is the number");
+
+Code (mcs):
+	IL_007c: ldc.i4.1 
+	IL_007d: box [mscorlib]System.Int32
+	IL_0082: ldstr " "
+	IL_0087: ldstr "is the number"
+	IL_008c: call string valuetype [corlib]System.String::Concat
+(string, string, string)
+
+OUTPUT:
+9 is the number
+
+Code (csc):
+	IL_006d: ldc.i4.1 
+	IL_006e: box [mscorlib]System.Int32
+	IL_0073: ldstr " is the number"
+	IL_0078: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+
+Case 7 good!: Console.WriteLine(j + " is the number");
+
+Code (mcs) same as csc:
+	IL_0096: ldloc.1 
+	IL_0097: box [mscorlib]System.Int32
+	IL_009c: ldstr " is the number"
+	IL_00a1: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+OUTPUT:
+1 is the number
+
+
+Case 8 good!: Console.WriteLine(1 + " is the number");
+
+Code (mcs) same as csc:
+	IL_00ab: ldc.i4.1 
+	IL_00ac: box [mscorlib]System.Int32
+	IL_00b1: ldstr " is the number"
+	IL_00b6: call string valuetype [corlib]System.String::Concat
+(object, object)
+
+
+OUTPUT:
+1 is the number
+
+
+How often does this happen? 
+When you have:
+int + string + string
+(and may be other cases)
+
+int + string
+works ok