Bug 324277 (MONO81601) - [Flow Analysis] [Confirmed] switch with goto case/default gives wrong IL when condition is literal
Summary: [Flow Analysis] [Confirmed] switch with goto case/default gives wrong IL when...
Status: RESOLVED FIXED
Alias: MONO81601
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other All
: P3 - Medium : Major
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-11 21:12 UTC by Kazuya Ujihara
Modified: 2013-11-26 12:11 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:38:21 UTC


---- Reported by ujihara@aurora.dti.ne.jp 2007-05-11 14:12:23 MST ----

Description of Problem:
'switch' statement including 'goto case' or 'goto default' statement 
gives wrong IL when the switch's condition is literal. 

Steps to reproduce the problem:

1. Compile and execute the following program.
public class A {
 public static void Main(string[] arg) {
  switch (10) {
   case 10:
    System.Console.Out.WriteLine(10);
    goto default;
   default:
    System.Console.Out.WriteLine("default");
    break;
  }
 }
}
 
Actual Results:
Unhandled Exception: System.InvalidProgramException: Invalid IL code in 
A:Main (string[]): IL_000c: br        IL_ffffffff

Expected Results:
10
default

How often does this happen? 

Always

Additional Information:
It also happens when we change 'goto default' into 'goto case 10'.

Comment 1 Thomas Wiest 2007-10-31 01:03:36 UTC
This bug's status has been confirmed on these versions of Mono:

1.2.2: Broken (default SLED 10 sp1)
1.2.5.1: Broken
r88511: Broken
Comment 3 Marek Safar 2007-11-05 17:13:16 UTC
Another flow-analysis issue.

The problem is that we emit constant block only.
The correct fix is to do flow analysis over all blocks and emit constant block and all remaining blocks marked which are used.
Comment 5 Susanne Oberhauser-Hirschoff 2011-07-20 12:30:11 UTC
Reassigning to Miguel to drive further resolution...
Comment 6 Marek Safar 2013-11-26 12:11:10 UTC
Fixed.