Bug 19353 - Duplicate Case Statement Crashes Compiler
Summary: Duplicate Case Statement Crashes Compiler
Alias: None
Product: Class Libraries
Classification: Mono
Component: Ms.Build ()
Version: unspecified
Hardware: Macintosh Mac OS
: Normal major
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-04-28 17:22 UTC by Kevin Mullins
Modified: 2014-04-29 11:08 UTC (History)
4 users (show)

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:

Description Kevin Mullins 2014-04-28 17:22:14 UTC
When compiling a Xamarin.Android application if a Switch statement contains a Case statement with a duplicate condition, the compiler is crashing with a code of 1.

Example Coding Error
switch (State) {
case TristatePosition.Off:
	thumbX = 0;
case TristatePosition.Off:
	thumbX = (width/2) - (thumbWidth/2);
case TristatePosition.Off:
	thumbX = width-thumbWidth;

Build Log Output
Task "Csc"
		Using task Csc from Microsoft.Build.Tasks.Csc, Microsoft.Build.Tasks.v4.0, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
		Tool /Library/Frameworks/Xamarin.Android.framework/Versions/Current/bin/smcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/TristateButton.dll /resource:obj/Debug/Android.CustomWidgets.TristateSwitch.obj.Debug.__AndroidLibraryProjects__.zip,__AndroidLibraryProjects__.zip Resources/Resource.designer.cs TristatePosition.cs TristateAppearance.cs TristateSwitch.cs obj/Debug/MonoAndroid,Version=v4.4.AssemblyAttribute.cs /target:library /define:"DEBUG;__MOBILE__;__ANDROID__;__MOBILE__;__ANDROID__;__ANDROID_1__;__ANDROID_2__;__ANDROID_3__;__ANDROID_4__;__ANDROID_5__;__ANDROID_6__;__ANDROID_7__;__ANDROID_8__;__ANDROID_9__;__ANDROID_10__;__ANDROID_11__;__ANDROID_12__;__ANDROID_13__;__ANDROID_14__;__ANDROID_15__;__ANDROID_16__;__ANDROID_17__;__ANDROID_18__;__ANDROID_19__" /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/System.dll /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/System.Xml.dll /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v4.4/Mono.Android.dll /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/System.Core.dll /warn:4
		TristateSwitch.cs(232,4): error CS0152: The label `case 0:' already occurs in this switch statement
		TristateSwitch.cs(229,4): (Location of the symbol related to previous error)
		TristateSwitch.cs(235,4): error CS0152: The label `case 0:' already occurs in this switch statement
		TristateSwitch.cs(229,4): (Location of the symbol related to previous error)
		Tool /Library/Frameworks/Xamarin.Android.framework/Versions/Current/bin/smcs execution finished.
/Library/Frameworks/Mono.framework/Versions/3.2.6/lib/mono/4.0/Microsoft.CSharp.Targets: error : Compiler crashed with code: 1.

This should report an error to the IDE and not crash the compiler.
Comment 2 Jonathan Pryor 2014-04-29 11:08:03 UTC
This is either Bug #19345 (the mcs crash) or Bug #14767 (xbuild isn't properly reporting error messages), both of which are fixed and will be present in a future mono release.

Again, these are Mono bugs, not Xamarin.Android bugs, and will require an updated system mono in order to be fixed (probably Mono 3.4+).