Bug 35401 - mcs generates incorrect code for CoreCLR try-finally03.cs and try-finally-struct03.cs test cases
Summary: mcs generates incorrect code for CoreCLR try-finally03.cs and try-finally-str...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-10-30 11:08 UTC by Alexander Köplinger [MSFT]
Modified: 2015-11-02 08:45 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
try-finally03.cs and try-finally-struct03.cs (1.86 KB, application/x-zip-compressed)
2015-10-30 11:08 UTC, Alexander Köplinger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Alexander Köplinger [MSFT] 2015-10-30 11:08:59 UTC
Created attachment 13585 [details]
try-finally03.cs and try-finally-struct03.cs

Compile the attached files (taken from the open source MS CoreCLR test suite) with mcs.

If you run the assembly produced by mcs with .NET or Mono, they fail (.NET prints some output, Mono just crashes).

Compile the files with csc/roslyn, now they both work on .NET and Mono.

A quick IL diff showed that csc emits an additional nop:

IL from mcs:
>.class public auto ansi beforefieldinit RefX0
>       extends [mscorlib]System.Object
>{
>  .method public hidebysig specialname rtspecialname 
>          instance void  .ctor() cil managed
>  {
>    // Code size       7 (0x7)
>    .maxstack  8
>    IL_0000:  ldarg.0
>    IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
>    IL_0006:  ret
>  } // end of method RefX0::.ctor
>
>} // end of class RefX0

IL from csc:

>.class public auto ansi beforefieldinit RefX0
>       extends [mscorlib]System.Object
>{
>  .method public hidebysig specialname rtspecialname 
>          instance void  .ctor() cil managed
>  {
>    // Code size       8 (0x8)
>    .maxstack  8
>    IL_0000:  ldarg.0
>    IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
>***    IL_0006:  nop
>    IL_0007:  ret
>  } // end of method RefX0::.ctor
>
>} // end of class RefX0


Reproduces on Mono 4.0 and master.
Comment 1 Marek Safar 2015-11-02 08:45:46 UTC
Fixed in master