Bug 318797 (MONO75878) - [PATCH] mcs generates unreachable code error for reachable code
Summary: [PATCH] mcs generates unreachable code error for reachable code
Status: RESOLVED MOVED
Alias: MONO75878
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-22 23:12 UTC by A. S.
Modified: 2007-09-15 21:24 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed bugfix + trivial error location fix (1.03 KB, patch)
2005-08-30 15:42 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:28:09 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"