[Mono-bugs] [Bug 599470] New: GMCS requires explicit no-arguments construtor - .NET does not

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Apr 24 10:10:49 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=599470

http://bugzilla.novell.com/show_bug.cgi?id=599470#c0


           Summary: GMCS requires explicit no-arguments construtor - .NET
                    does not
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: i386
        OS/Version: Linux
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ohh at scisoft.dk
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.2.3)
Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)

This may be somewhat related to BUG 599469.

When compiling the file in the "Steps to reproduce" section GMCS fails to
compile and demands that an explicit no arguments constructor be added. The
compiler in .NET does not require this.

When a simple "do-nothing no-arguments" constructor is added the file compiles
(but does not execute - see bug 599469).

Reproducible: Always

Steps to Reproduce:
-bash-4.0$ cat test.cs
public class Grid<CT>
        where CT : Grid<CT>.GPD.GC, new()
{
        public abstract class GPD
        {
                public GPD()
                {
                        ctInst = new CT();
                }

                public readonly CT ctInst;

                public abstract class GC
                {
                }
        }
}

public class H : Grid<H.MyCT>.GPD
{
        public class MyCT : GC
        {
                // When no explicit default constructor is present GMCS fails
to compile the file.
                // When it is present the execution crashes on mono.
        //      public MyCT () {}
        }
}

public class TheTest
{
        public static void Main (string[] args)
        {
                new H();
        }
}
-bash-4.0$ gmcs test.cs
Actual Results:  
-bash-4.0$ gmcs test.cs
test.cs(19,31): error CS0310: The type `H.MyCT' must have a public
parameterless constructor in order to use it as parameter `CT' in the generic
type or method `Grid<CT>.GPD'
test.cs(4,31): (Location of the symbol related to previous error)
test.cs(21,22): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings


Expected Results:  
The file should compile without any errors. When building on .NET:
C:\Users\ohh\work\mono>csc Test.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.4016
til Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. Alle rettigheder forbeholdes.


C:\Users\ohh\work\mono>

-- 
Configure bugmail: http://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