[Mono-bugs] [Bug 435747] New: gmcs improperly compiles multiple value-type assignments on a single line.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Oct 15 13:25:12 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=435747
Summary: gmcs improperly compiles multiple value-type assignments
on a single line.
Product: Mono: Compilers
Version: 2.0
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: peter at peterjohanson.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
I found this funkiness while using Mono 2.0:
Consider the following lines:
DateTime dt;
DateTime other_dt = dt = new DateTime (633596616517216000);
Console.WriteLine ("other_dt: {0}, dt: {1}", other_dt, dt);
DateTime other_dt2 = dt = DateTime.Now;
Console.WriteLine ("other_dt2: {0}, dt: {1}", other_dt2, dt);
One would expect other_dt and dt to be equal, and later, for other_dt2 to be
equal to dt.
However, with mono 2.0, the following IL snippet gets generated:
.locals init (
valuetype [mscorlib]System.DateTime V_0,
valuetype [mscorlib]System.DateTime V_1,
valuetype [mscorlib]System.DateTime V_2)
IL_0000: ldloca.s 1
IL_0002: ldc.i8 0x8cafcc40a65e700
IL_000b: call instance void valuetype
[mscorlib]System.DateTime::'.ctor'(int64)
IL_0010: ldstr "other_dt: {0}, dt: {1}"
IL_0015: ldloc.1
IL_0016: box [mscorlib]System.DateTime
IL_001b: ldloc.0
IL_001c: box [mscorlib]System.DateTime
IL_0021: call void class [mscorlib]System.Console::WriteLine(string,
object, object)
IL_0026: call valuetype [mscorlib]System.DateTime valuetype
[mscorlib]System.DateTime::get_Now()
IL_002b: dup
IL_002c: stloc.0
IL_002d: stloc.2
IL_002e: ldstr "other_dt2: {0}, dt: {1}"
IL_0033: ldloc.2
IL_0034: box [mscorlib]System.DateTime
IL_0039: ldloc.0
IL_003a: box [mscorlib]System.DateTime
IL_003f: call void class [mscorlib]System.Console::WriteLine(string,
object, object)
As you can see, the V_0 local *never* gets set for the first case. Test case
attached. I can post the IL generated by csc from MS .NET 2.0 if you would like
to compare.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list