Bug 318975 (MONO76084) - [GMCS] Box instance_expr in Invocation.EmitCall() if it's a type parameter
Summary: [GMCS] Box instance_expr in Invocation.EmitCall() if it's a type parameter
Status: RESOLVED FIXED
Alias: MONO76084
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Linux
: P3 - Medium : Major
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-13 17:04 UTC by Michał Ziemski
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Test case (10.98 KB, text/plain)
2005-09-13 17:05 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:30:27 UTC


---- Reported by rook@roo.k.pl 2005-09-13 10:04:41 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:


Steps to reproduce the problem:
1. Compile the example
2. run it
3. 

Actual Results:
Shows "Trace/breakpoint trap"

Expected Results:
Should not show anything at all.

How often does this happen? 
Always

Additional Information:



---- Additional Comments From rook@roo.k.pl 2005-09-13 10:05:49 MST ----

Created an attachment (id=168499)
Test case




---- Additional Comments From kiess@h3c.de 2005-09-14 13:05:06 MST ----

A shorter testcase:

public interface SomeInterface
{
  bool Valid { get; }
}

public struct SomeStruct : SomeInterface
{
  public bool Valid {
    get {     
      return false;
    }
  }
}

public class Test
{
  public static void Fun<T>(T t) where T:SomeInterface {
    bool a = t.Valid;
  }

  static void Main()
  {
    Fun(new SomeStruct());
  }
}


The program compiles fine.
When running on mono 1.1.19 it fails with "Trace/breakpoint trap".
When running on mono svn head, it fails with:
** ERROR **: Invalid IL code at IL0001 in Test:Fun (SomeStruct):
IL_0001: callvirt  0x06000001


aborting...

However the assembly seems to be ok:
    // method line 4
    .method public static  hidebysig
           default void Fun<(class SomeInterface) T> (!!T t)  cil managed
    {
        // Method begins at RVA 0x20f8
        // Code size 8 (0x8)
        .maxstack 2
        .locals init (
                bool    V_0)
        IL_0000:  ldarg.0
        IL_0001:  callvirt instance bool class SomeInterface::get_Valid()
        IL_0006:  stloc.0
        IL_0007:  ret
    } // end of method Test::default void Fun<(class SomeInterface) T>
(!!T t)




---- Additional Comments From martin@ximian.com 2005-09-19 13:36:39 MST ----

This one should be easy - Invocation.EmitCall() must check whether the
`instance_expr' is a type parameter and box it.



---- Additional Comments From miguel@ximian.com 2005-09-25 13:08:43 MST ----

Hari, can you fix this?



---- Additional Comments From rharinath@novell.com 2005-09-30 03:30:56 MST ----

Hmm, I think it should have the 'constrained.' prefix instead of
boxing the instance.





---- Additional Comments From rharinath@novell.com 2005-10-10 09:15:02 MST ----

Committed a patch to MCS (svn r51512) that, when merged into GMCS,
should fix this bug.



---- Additional Comments From rharinath@novell.com 2005-10-11 09:28:16 MST ----

Should be fixed by the merge in SVN r51561


Imported an attachment (id=168499)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>FC4 Mono 1.1.9 (from www.nrpms.net)</cf_op_sys_details>