[Mono-bugs] [Bug 82111][Nor] New - mcs/gmcs fails to throw errors CS053/CS054 when abstract child of abstract class hides abstract members improperly

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jul 16 14:33:23 EDT 2007

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 sanfordarmstrong at gmail.com.


--- shadow/82111	2007-07-16 14:33:23.000000000 -0400
+++ shadow/82111.tmp.11255	2007-07-16 14:33:23.000000000 -0400
@@ -0,0 +1,106 @@
+Bug#: 82111
+Product: Mono: Compilers
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: sanfordarmstrong at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: mcs/gmcs fails to throw errors CS053/CS054 when abstract child of abstract class hides abstract members improperly
+Description of Problem:
+See summary.  Here's a test case that should fail to compile, but does not
+fail with (g)mcs
+namespace AbstractTest
+    public abstract class MyAbstractBase
+    {
+        public abstract void Initialize();
+    }
+    public abstract class MyAbstract : MyAbstractBase
+    {
+        public virtual void Initialize() {
+            System.Console.WriteLine("MyAbstract Initialized!");
+        }
+    }
+    public class MyConcrete : MyAbstract { }
+    public class Program
+    {
+        public static void Main(string[] args)
+        {
+            MyAbstractBase gonnaFail = new MyConcrete();
+            gonnaFail.Initialize();
+        }
+    }
+Actual Results:
+Compilation succeeded with both gmcs and mcs, version, with the
+following output:
+X:\sandbox\AbstractTest\AbstractTest>c:\mono-1.2.3\bin\gmcs Program.cs
+Program.cs(10,29): warning CS0114: `AbstractTest.MyAbstract.Initialize()'
+hides inherited member `AbstractTest.MyAbstractBase.Initialize()'. To make
+the current member override that implementation, add the override keyword.
+Otherwise add the new keyword
+Program.cs(5,30): (Location of the symbol related to previous warning)
+Compilation succeeded - 1 warning(s)
+Of course it then fails at runtime.  On Linux, with a similar test case, I
+received a very cryptic native stacktrace (I can attach later if
+necessary).  On Windows with this test case I simply receive:
+Unhandled Exception: System.TypeLoadException: Method 'Initialize' in type
+'AbstractTest.MyConcrete' from assembly 'Program,
+Version=,Culture=neutral, PublicKeyToken=null' does not have an
+   at AbstractTest.Program.Main(String[] args)
+Expected Results:
+In Visual Studio 2005, compilation fails, with the following output:
+C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
+/nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE
+/debug+ /debug:full /optimize- /out:obj\Debug\AbstractTest.exe /target:exe
+Program.cs Properties\AssemblyInfo.cs
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(10,29): warning CS0114:
+'AbstractTest.MyAbstract.Initialize()' hides inherited member
+'AbstractTest.MyAbstractBase.Initialize()'. To make the current member
+override that implementation, add the override keyword. Otherwise add the
+new keyword.
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(5,30): (Related location)
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(10,29): error CS0533:
+'AbstractTest.MyAbstract.Initialize()' hides inherited abstract member
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(5,30): (Related location)
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(15,18): error CS0534:
+'AbstractTest.MyConcrete' does not implement inherited abstract member
+x:\sandbox\AbstractTest\AbstractTest\Program.cs(5,30): (Related location)
+Compile complete -- 2 errors, 1 warnings
+How often does this happen? 
+Every time.  I first noticed it with gmcs on Ubuntu 6.10.  I have
+not tested with 1.2.4.x.

More information about the mono-bugs mailing list