Bug 323805 (MONO81121) - [GMCS] crash on unassigned new of generic type
Summary: [GMCS] crash on unassigned new of generic type
Status: RESOLVED FIXED
Alias: MONO81121
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-12 19:47 UTC by Andy Mortimer
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

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


---- Reported by andy.mortimer@ansys.com 2007-03-12 12:47:46 MST ----

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

Crash trying to compile code which creates a new object of the generic
parameter for a class, but does not assign that new object to a variable.

Steps to reproduce the problem:
1. Create a file newcrash.cs containing the small class:

public class SomeClass<T> where T : new() {
    public void Foo() {
        new T();
    }
}

2. gmcs /target:library newcrash.cs

Actual Results:

Compiler crashes with the following stack trace:

Unhandled Exception: System.InvalidOperationException: Operation is not
valid due to the current state of the object
  at Mono.CSharp.New.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec)
[0x00000]
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000]
  at Mono.CSharp.EmitContext.EmitResolvedTopBlock
(Mono.CSharp.ToplevelBlock block, Boolean unreachable) [0x00000]
  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00000]
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000]
  at Mono.CSharp.Method.Emit () [0x00000]
  at Mono.CSharp.TypeContainer.EmitType () [0x00000]
  at Mono.CSharp.RootContext.EmitCode () [0x00000]
  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000]
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000]

(This trace is with 1.2.2.1; I'm told it also fails with the latest
development version, but I don't know if the stack trace is the same.)

Expected Results:

Successful compilation.

How often does this happen? 

Every time.

Additional Information:

Assigning the result of the new() call to a variable prevents the crash:

public class SomeClass<T> where T : new() {
    public void Foo() {
        T obj = new T();
    }
}



---- Additional Comments From rharinath@novell.com 2007-03-29 10:33:22 MST ----

Should be fixed in SVN r75139.


Unknown operating system unknown. Setting to default OS "Other".