Bug 38379 - Byte enums fail to compare correctly on 64 bit iOS devices when using the LLVM compiler
Summary: Byte enums fail to compare correctly on 64 bit iOS devices when using the LLV...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: XI 9.4 (iOS 9.2)
Hardware: PC Mac OS
: Normal normal
Target Milestone: (C7)
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2016-02-03 17:04 UTC by John Miller [MSFT]
Modified: 2016-06-02 13:31 UTC (History)
5 users (show)

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


Attachments
Sample Project (11.13 KB, application/zip)
2016-02-03 17:04 UTC, John Miller [MSFT]
Details

Description John Miller [MSFT] 2016-02-03 17:04:55 UTC
Created attachment 14865 [details]
Sample Project

**Overview:**

   Passing an enum to a function results in an unsigned to signed conversion error.

- The enum has a byte as its underlying type ( public enum MyEnum : byte { )

- The enum value is higher than 127 (last bit of the byte is set)

- The enum is passed as an argument to a method

- Compiled with the LLVM compiler

- Running on a 64 bit iOS device

**Steps to Reproduce:**

   Run the attached sample on a 64 bit device in Release mode.

**Actual Results:**

Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: low: Low (1)
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: low==TestEnum.Low: True
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: low==TestEnum.High: False
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 low: Low (1)
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 low==TestEnum.Low: True
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 low==TestEnum.High: False
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: high: High (142)
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: high==TestEnum.Low: False
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: high==TestEnum.High: True
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 high: High (-114)
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 high==TestEnum.Low: False
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod1 high==TestEnum.High: False
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: highByte: 142
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: highByte==142: True
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod2 highByte: 142
Feb  3 11:59:48 Johns-iPhone Case256903[2741] <Warning>: TestMethod2 highByte==142: True

**Expected Results:**

2016-02-03 11:58:18.778 Case256903[2727:1275041] low: Low (1)
2016-02-03 11:58:18.779 Case256903[2727:1275041] low==TestEnum.Low: True
2016-02-03 11:58:18.779 Case256903[2727:1275041] low==TestEnum.High: False
2016-02-03 11:58:18.779 Case256903[2727:1275041] TestMethod1 low: Low (1)
2016-02-03 11:58:18.779 Case256903[2727:1275041] TestMethod1 low==TestEnum.Low: True
2016-02-03 11:58:18.780 Case256903[2727:1275041] TestMethod1 low==TestEnum.High: False
2016-02-03 11:58:18.780 Case256903[2727:1275041] high: High (142)
2016-02-03 11:58:18.780 Case256903[2727:1275041] high==TestEnum.Low: False
2016-02-03 11:58:18.780 Case256903[2727:1275041] high==TestEnum.High: True
2016-02-03 11:58:18.780 Case256903[2727:1275041] TestMethod1 high: High (142)
2016-02-03 11:58:18.781 Case256903[2727:1275041] TestMethod1 high==TestEnum.Low: False
2016-02-03 11:58:18.781 Case256903[2727:1275041] TestMethod1 high==TestEnum.High: True
2016-02-03 11:58:18.781 Case256903[2727:1275041] highByte: 142
2016-02-03 11:58:18.781 Case256903[2727:1275041] highByte==142: True
2016-02-03 11:58:18.781 Case256903[2727:1275041] TestMethod2 highByte: 142
2016-02-03 11:58:18.781 Case256903[2727:1275041] TestMethod2 highByte==142: True

**Build Date & Platform:**

=== Xamarin Studio ===

Version 6.0 (build 3972)
Installation UUID: e01c3049-a2d2-4e0a-aad8-afe6fb627c4d
Runtime:
	Mono 4.3.0 (mono-4.3.1-branch/37d269c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 403002114

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.1.24 (Business Edition)
Hash: 47eb74b4
Branch: master
Build date: 2016-01-20 17:06:01-0500

=== Xamarin.Android ===

Version: 6.0.1.10 (Business Edition)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.1.6 (Business Edition)

=== Build Information ===

Release ID: 600003972
Git revision: 13d34c7e71cd2c7b50755aa208098af266183182
Build date: 2016-02-03 04:57:27-05
Xamarin addins: 67dfdbcfcb8829ac39cccf80888ef9181dde7169
Build lane: monodevelop-lion-roslyn-dark-skin

=== Operating System ===

Mac OS X 10.11.2

**Additional Information:**

   The issue is gone if we compile without the LLVM compiler or run on a 32 bit iOS device.
Comment 1 Zoltan Varga 2016-02-03 23:21:35 UTC
Fixed in mono master bac71d3d9aa147f31c26b4b69dd145e2cb041b87.

This is a low risk change which could be a candidate for c6sr2.
Comment 3 GouriKumari 2016-03-03 16:30:27 UTC
This will be mow included with C7, hence changing the milestone.

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

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