[Mono-bugs] [Bug 27969][Nor] New - mcs compiles invalid code (allows manually calling constructor in base class)

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
18 Jul 2002 17:50:31 -0000


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 larsde@redloop.com.

http://bugzilla.ximian.com/show_bug.cgi?id=27969

--- shadow/27969	Thu Jul 18 13:50:31 2002
+++ shadow/27969.tmp.20390	Thu Jul 18 13:50:31 2002
@@ -0,0 +1,88 @@
+Bug#: 27969
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: larsde@redloop.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs compiles invalid code (allows manually calling constructor in base class)
+
+Description of Problem:
+
+Given classes ClassA and subclass ClassB, ClassB is allowed to manually 
+invoke the constructor in the base class if base class provides a default 
+constructor. The default constructor is always called even if it doesn't 
+match the signature of the call.
+
+If called from constructor in ClassB, constructor does not finish 
+executing.
+
+Steps to reproduce the problem:
+
+Try compiling this code
+
+using System;
+
+namespace ConsTest
+{
+
+	class ClassA 
+	{
+
+		public ClassA() 
+		{
+			Console.WriteLine("Defaultconstructor");
+		}
+
+		public ClassA(string p_string) 
+		{
+			Console.WriteLine(p_string + " from ClassA");
+		}
+	}
+
+	class ClassB : ClassA
+	{
+		public ClassB(string p_string) 
+		{
+			base.ClassA(p_string);
+			Console.WriteLine("From ClassB: " + p_string);
+		}
+
+		[STAThread]
+		static void Main(string[] args)
+		{
+			ClassB t_b = new ClassB("Yoyoyo");
+		}
+	}
+}
+
+Actual Results:
+
+"Defaultconstructor" is output to console.
+
+Expected Results:
+
+I expected it not to compile. Microsoft's C#-compiler outputs: 
+
+C:\Documents and Settings\Lars Thomas Denstad\My 
+Documents\Projects\MonoTests\ConsTest\Class1.cs(33): 'ConsTest.ClassA' 
+does not contain a definition for 'ClassA'
+
+How often does this happen? 
+
+Every time.
+
+Additional Information:
+
+Experienced with mcs downloaded today from 
+http://www.superin.formativ.net/mono/download.htm (mono-0.12-15-7-
+2002.exe), Windows XP.