Bug 55400 - MCS produces incorrect code for generic instantiated with a gtd
Summary: MCS produces incorrect code for generic instantiated with a gtd
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 5.0.0 (2017-02)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2017-04-19 18:56 UTC by Aleksey Kliger
Modified: 2017-05-24 17:30 UTC (History)
1 user (show)

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

Repro.cs (324 bytes, text/plain)
2017-04-19 18:56 UTC, Aleksey Kliger

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:

Description Aleksey Kliger 2017-04-19 18:56:40 UTC
Created attachment 21640 [details]

  1.  mcs Repro.cs
  2.  csc Repro.cs

Expected Result:
  Both mcs and csc produce the error:
     error CS7003: Unexpected use of an unbound generic name

Actual Result:
  csc gives an error.  mcs produces an assembly with the following Main:
  .method public hidebysig static void  Main(string[] args) cil managed
    // Code size       18 (0x12)
    .maxstack  1
    .locals init (class [mscorlib]System.Type V_0)
    IL_0000:  ldtoken    Test.B`1
    IL_0005:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    IL_000a:  stloc.0
    IL_000b:  ldloc.0
    IL_000c:  call       void [mscorlib]System.Console::WriteLine(object)
    IL_0011:  ret
  } // end of method Repro::Main

ie, it actually just behaves as if I wrote typeof (Test.B<>)
Comment 1 Marek Safar 2017-05-24 17:30:45 UTC
Fixed in master