[Mono-bugs] [Bug 322485] Invalid IL code in System.Nullable::Equals
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Nov 8 13:20:17 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=322485#c2
Rodrigo Kumpera <rkumpera at novell.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rkumpera at novell.com
Component|CORLIB |C#
Product|Mono: Class Libraries |Mono: Compilers
Version|1.1 |1.2
--- Comment #2 from Rodrigo Kumpera <rkumpera at novell.com> 2007-11-08 11:20:16 MST ---
It looks like a compiler bug.
gmcs generates the following IL for System.Nullable.Equals<T>. The code seens
to be wrong as you cannot pass an unboxed valuetype to a parameter of type
object.
.method public hidebysig static bool Equals<valuetype T>(valuetype
System.Nullable`1<!!T> value1,
valuetype System.Nullable`1<!!T> value2) cil managed
{
// Code size 9 (0x9)
.maxstack 8
IL_0000: ldarga.s value1
IL_0002: ldarg.1
IL_0003: call instance bool valuetype
System.Nullable`1<!!T>::Equals(object)
IL_0008: ret
} // end of method Nullable::Equals
Interesting enough, if the same method is compiled on a class outside corlib,
the generated IL is correct:
.method public hidebysig static bool Equals<valuetype T>(valuetype
[mscorlib] System.Nullable`1<!!T> value1, valuetype [mscorlib]
System.Nullable`1<!!T> value2) cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldarga.s value1
IL_0002: ldarg.1
IL_0003: box valuetype [mscorlib]System.Nullable`1<!!T>
IL_0008: call instance bool valuetype
[mscorlib]System.Nullable`1<!!T>::Equals(object)
IL_000d: ret
} // end of method Driver::Equals
CSC generates a slightly diferent IL from the above:
.method public hidebysig static bool Equals<valuetype .ctor
([mscorlib]System
ValueType) T>(valuetype [mscorlib]System.Nullable`1<!!T> value1,
valuetype [mscorlib]System.Nullable`1<!!T> value2) cil managed
{
// Code size 25 (0x19)
.maxstack 2
.locals init (bool V_0)
IL_0000: nop
IL_0001: ldarga.s value1
IL_0003: ldarg.1
IL_0004: box valuetype [mscorlib]System.Nullable`1<!!T>
IL_0009: constrained. valuetype [mscorlib]System.Nullable`1<!!T>
IL_000f: callvirt instance bool [mscorlib]System.Object::Equals(object)
IL_0014: stloc.0
IL_0015: br.s IL_0017
IL_0017: ldloc.0
IL_0018: ret
} // end of method Driver::Equals
--
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