[Mono-bugs] [Bug 51347][Nor] New - Incorrect string concatenation in string array initializers
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 24 Nov 2003 11:25:13 -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 l_m@pacbell.net.
http://bugzilla.ximian.com/show_bug.cgi?id=51347
--- shadow/51347 2003-11-24 11:25:13.000000000 -0500
+++ shadow/51347.tmp.8969 2003-11-24 11:25:13.000000000 -0500
@@ -0,0 +1,69 @@
+Bug#: 51347
+Product: Mono/MCS
+Version: unspecified
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: l_m@pacbell.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Incorrect string concatenation in string array initializers
+
+Description of Problem:
+Incorrect string concatenation in string array initializers
+
+With the following source:
+
+using System;
+
+public class Test {
+
+ private static string B = "B";
+ private static string[] S = { "A" + B + "C"} ;
+
+ public static void Main () {
+ Console.WriteLine (S [0]);
+ }
+}
+
+mcs will generate:
+
+IL_0014: ldstr "A"
+IL_0019: ldsfld string 'Test'::'B'
+IL_001e: ldstr "C"
+IL_0023: ldstr "C" <---- should not be here
+IL_0028: call string valuetype
+[mscorlib]'System.String'::'Concat'(string, string, string, string)
+
+Here's a patch to fix the problem (note: since we are not reusing args
+anymore, it is not necessary to have the initial capacity set to 4).
+
+Index: expression.cs
+===================================================================
+RCS file: /cvs/public/mcs/mcs/expression.cs,v
+retrieving revision 1.498
+diff -u -b -r1.498 expression.cs
+--- expression.cs 22 Nov 2003 02:52:16 -0000 1.498
++++ expression.cs 24 Nov 2003 15:59:40 -0000
+@@ -2310,7 +2310,7 @@
+ //
+ if (b.method ==
+TypeManager.string_concat_string_string ||
+ b.method ==
+TypeManager.string_concat_string_string_string){
+- ArrayList
+bargs = b.Arguments;
++ ArrayList
+bargs = new ArrayList (b.Arguments);
+ int count
+= bargs.Count;
+
+ if (count
+== 2){