Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=81180 --- shadow/81180 2007-03-18 22:49:26.000000000 -0500 +++ shadow/81180.tmp.7799 2007-03-18 22:49:26.000000000 -0500 @@ -0,0 +1,52 @@ +Bug#: 81180 +Product: Mono: Compilers +Version: 1.2 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: GMCS does not enforce reference type constraint + +GMCS appears to allow one to instantiate generic classes using value types +for paramaters that have the reference type constraint. The following code +shouldn't, I think, compile: + +namespace Application +{ + public class TestClass<T> where T : class + { + static public T meth() + { + return null; + } + } + + public class Test + { + + public Test() + { + } + + static public void Main() + { + int i = TestClass<int>.meth(); + System.Console.WriteLine(i); + } + } +} + +"where T : class" should constrain T to be a reference type, which int is +not. Furthermore, TestClass.meth returns null, which one shouldn't be able +to assign to an int. + +But, on version 1.2.3.1, it compiles and the resulting executable outputs "0". _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
