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
Depends on:
Reported: 2013-11-24 18:24 UTC by Jérémie Laval
Modified: 2014-01-29 16:25 UTC (History)
3 users (show)

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


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.


switch (position) {
	case 0:
		return ...;
	case 1:
		return ...;
	case 1:
		return ...;
		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;
	        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:


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 ***

Note You need to log in before you can comment on or make changes to this bug.