[Mono-bugs] [Bug 353800] New: Compiler generates extra unreachable CIL code at end of delegates.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 14 18:25:06 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=353800


           Summary: Compiler generates extra unreachable CIL code at end of
                    delegates.
           Product: Mono: Compilers
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jan.oravec at 6com.sk
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


While hunting bug in Cecil.FlowAnalysis I have found out that delegates and
lambda functions contains extra instructions at end:

simple delegate () { return; } compiles with extra 'ret':

    .method assembly hidebysig 
           instance default void '<Main>c__1' ()  cil managed 
    {
        .custom instance void class
[mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() =
 (01 00 00 00 ) // ....

        // Method begins at RVA 0x2158
        // Code size 2 (0x2)
        .maxstack 8
        IL_0000:  ret 
        IL_0001:  ret 
    } // end of method <>c__CompilerGenerated0::<Main>c__1

simple delegate () { return 0; } compiles as:

    .method assembly hidebysig 
           instance default int32 '<Main>c__1'<TResult> ()  cil managed 
    {
        .custom instance void class
[mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() =
 (01 00 00 00 ) // ....

        // Method begins at RVA 0x2158
        // Code size 4 (0x4)
        .maxstack 2
        .locals init (
                int32   V_0)
        IL_0000:  ldc.i4.0 
        IL_0001:  ret 
        IL_0002:  ldloc.0 
        IL_0003:  ret 
    } // end of method <>c__CompilerGenerated0::<Main>c__1


This triggered bug in Cecil.FlowAnalysis, where ControlFlowGraphBuilder doesn't
visit unreachable instructions and later ActionFlowGraphBuilder fails while
walking thru InstructionBlocks not visited by ControlFlowGraphBuilder.

So, these are actually 2 bugs. I am not sure where Cecil bugs should be
submitted.


-- 
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