[Mono-bugs] [Bug 421811] New: [gmcs] ICE when compiling constraints clause

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Aug 31 16:52:35 EDT 2008


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


           Summary: [gmcs] ICE when compiling constraints clause
           Product: Mono: Compilers
           Version: SVN
          Platform: x86-64
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


gmcs version: r111929.

Compile the following code:

  using System;
  using System.Collections.Generic;

  using Mono.Rocks;

  namespace Mono.Rocks {

    public struct Tuple<T1, T2>
    {
      private T1 value1;
      private T2 value2;

      public Tuple (T1 value1, T2 value2)
      {
        this.value1 = value1;
        this.value2 = value2;
      }

      [CLSCompliant (false)]
      public T1 _1 {get{return value1;}}

      [CLSCompliant (false)]
      public T2 _2 {get{return value2;}}

      public IEnumerable<TResult> Cast<TResult> ()
        where TResult : T1, T2
      {
        yield return (TResult) _1;
        yield return (TResult) _2;
      }
    }
  }

  class Test {
    public static void Main()
    {
      Tuple<int, int> t = new Tuple<int, int> (1, 2);
      // IEnumerable<int> a = t.Cast ();
      IEnumerable<int> a = t.Cast<int> ();
    }
  }

Expected output: No error, maybe a few warnings about CLSCompliant, etc.

Actual output:

jon at lina:tmp$ gmcs Tuples.cs
Tuples.cs(20,17): warning CS3021: `Mono.Rocks.Tuple<T1,T2>._1' does not need a
CLSCompliant attribute because the assembly is not marked as CLS-compliant
Tuples.cs(23,17): warning CS3021: `Mono.Rocks.Tuple<T1,T2>._2' does not need a
CLSCompliant attribute because the assembly is not marked as CLS-compliant
Exception caught by the compiler while compiling:
   Block that caused the problem begin at: Tuples.cs(35,24):
                     Block being compiled: [Tuples.cs(39,7):,Tuples.cs(39,42):]
System.IndexOutOfRangeException: Array index is out of range.
Internal compiler error at Tuples.cs(35,24):: exception caught while emitting
MethodBuilder [Test::Main]

Unhandled Exception: System.IndexOutOfRangeException: Array index is out of
range.
  at Mono.CSharp.ConstraintChecker.CheckConstraint (IResolveContext ec,
System.Type ptype, Mono.CSharp.Expression expr, System.Type ctype) [0x00000] 
  at Mono.CSharp.ConstraintChecker.CheckConstraints (IResolveContext ec, Int32
index) [0x00000] 
  at Mono.CSharp.ConstraintChecker.CheckConstraints (IResolveContext ec)
[0x00000] 
  at Mono.CSharp.ConstraintChecker.CheckConstraints (Mono.CSharp.EmitContext
ec, System.Reflection.MethodBase definition, System.Reflection.MethodBase
instantiated, Location loc) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList& Arguments, Boolean may_fail, Location loc)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Assign.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.SimpleAssign.DoResolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000] 
  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext
ec) [0x00000] 
  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext
anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters
ip, IMethodData md, System.Boolean& unreachable) [0x00000] 

Apparently gmcs doesn't like a constraints clause referencing multiple type
parameters from the enclosing scope.

NET 3.5 CSC compiles this code w/o error.


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