Bug 16428 - Compiler crash with duplicate switch labels
Summary: Compiler crash with duplicate switch labels
Status: RESOLVED DUPLICATE of bug 14767
Alias: None
Product: Tools
Classification: Mono
Component: xbuild (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-11-24 18:24 UTC by Jérémie Laval
Modified: 2014-01-29 16:25 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 14767

Description Jérémie Laval 2013-11-24 18:24:56 UTC
Activity.cs(56,5): error CS0152: The label `case 1:' already occurs in this switch statement
Activity.cs(54,5): (Location of the symbol related to previous error)
/Library/Frameworks/Mono.framework/Versions/3.2.5/lib/mono/4.0/Microsoft.CSharp.Targets: error : Compiler crashed with code: 1.

Code:

switch (position) {
	case 0:
		return ...;
	case 1:
		return ...;
	case 1:
		return ...;
	default:
		return ...;
}
Comment 1 Marek Safar 2013-11-25 08:12:43 UTC
I cannot reproduce it. I probably crashes somewhere else. My repro is

class C
{
	public static int Main ()
	{
		return 0;
	}

	static int Foo (int position)
	{
		switch (position) {
	    case 0:
	        return 1;
	    case 1:
	        return 2;
	    case 1:
	        return 3;
	    default:
	        return 4;
	    }
	}
}
Comment 2 Jérémie Laval 2013-11-26 22:59:28 UTC
Upon closer investigation, it doesn't actually seem to crash but instead exit normally with a 1 code which seems to make xbuild (and thus X.S) think that the compiler crashed.
Comment 3 Jérémie Laval 2013-11-26 23:15:23 UTC
Indeed, the issue is that when executed under xbuild, the mcs output line `Activity.cs(56,5): error CS0152: The label `case 1:' already occurs in this switch statement' is not recognized as an error and thus the msbuild ManagedCompiler task thinks it's a crash.

AFAICT, testing with the regex https://github.com/mono/mono/blob/master/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs#L468 that message should parse correctly but for some reason under xbuild it's not.

You can notice this since another error does print red under xbuild: http://screencast.com/t/HWRTXDNthF
But not our friend the label: http://screencast.com/t/PKiiqIOm
Comment 4 Marek Safar 2013-11-27 02:53:18 UTC
jonp touched this code last ;-)
Comment 5 Jonathan Pryor 2014-01-29 16:25:43 UTC
@Jeremie: Which Mono version do you see this on? Does it contain commit mono/7a2d2c24? Your error message is used as a test:

https://github.com/mono/mono/commit/7a2d2c247c481c291fed5f7f1213189d9426108a#diff-e9b369480cec74149745daa7f1d1d6ceR48

Mono 3.2.5 does not contain the above fix. Nor does 3.2.6 (at least according to `git log origin/mono-3.2.6-branch`).

Based on the current branches, this should be fixed in 3.2.7.

*** This bug has been marked as a duplicate of bug 14767 ***