Bugzilla – Bug 318797
[PATCH] mcs generates unreachable code error for reachable code
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by ash@onezero.org 2005-08-22 16:12:29 MST ---- Hi. mcs reports this: | mcs --version Mono C# compiler version 1.1.8.0 | mcs t.cs t.cs(8) warning CS0162: Unreachable code detected Compilation succeeded - 1 warning(s) But in t.cs, all code is reachable, as can be demonstrated by running the program "t hello" and "t": using System; class Hello { public Hello() { d_n = 0; } public bool Test(int n) { d_n = 0; test(n); if (d_n > 0) { goto theend; } return false; theend: return true; } ////// private int d_n; void test(int n) { d_n = n; } } class Test { public static void Main(string[] args) { Hello h = new Hello(); Console.WriteLine("result = {0}", h.Test(args.Length)); } } Maybe the compiler has an error somewhere in its reachability computations where goto statements are not treated properly with respect to data members. My build setup is for warnings to be treated as errors, so this is a fairly iritating problem for me as I do not want to switch back and forth between "treat warnings as errors" and "don't treat warnings as errors". ---- Additional Comments From atsushi@ximian.com 2005-08-30 08:42:53 MST ---- Created an attachment (id=168400) proposed bugfix + trivial error location fix ---- Additional Comments From martin@ximian.com 2006-03-21 18:55:00 MST ---- *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO77869 *** Imported an attachment (id=168400) Unknown operating system Windows XP (Cygwin). Setting to default OS "Other". This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"