Bug 448558

Summary: gmcs emits unverifiable generic code
Product: [Mono] Mono: Compilers Reporter: Rolf Kvinge <rkvinge>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED DUPLICATE QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: SVN   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Rolf Kvinge 2008-11-25 10:12:20 UTC
Test sample:
class T {
        public P GetService <P> () where P : class
        {
            return null;
        }
}

gmcs il:
.method public hidebysig instance !!P GetService<class P>() cil managed
{
    .maxstack 8
    L_0000: ldnull 
    L_0001: ret 
}

csc il:
.method public hidebysig instance !!P GetService<class P>() cil managed
{
    .maxstack 1
    .locals init (
        [0] !!P local)
    L_0000: ldloca.s local
    L_0002: initobj !!P
    L_0008: ldloc.0 
    L_0009: ret 
}

peverify says (out gmcs):
[IL]: Error: [test.dll : T::GetService[P]][offset 0x00000001][found Nullobjref 'NullReference'][expected (unboxed) 'P'] Unexpected type on the stack.
1 Error(s) Verifying test.dll
Comment 1 Marek Safar 2008-11-25 16:56:31 UTC

*** This bug has been marked as a duplicate of bug 324319 ***