Bug 33723

Summary: Null propagation operator produces incorrect IL
Product: [Mono] Compilers Reporter: Jahmai <jahmai>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: kumpera, masafa, mono-bugs+monotouch, mono-bugs+mono, sebastien
Priority: ---    
Version: 4.0.0   
Target Milestone: 4.2.0 (C6)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Jahmai 2015-09-06 08:17:39 UTC
The following code returns false when "keyUsage" is null:

                    X509KeyUsageExtension keyUsage = (extension as X509KeyUsageExtension);

                    if ((keyUsage?.KeyUsages & X509KeyUsageFlags.DigitalSignature) == X509KeyUsageFlags.None)
                        return false;

Actually, it should pass through the condition. This is how the code should expand:

                    X509KeyUsageExtension keyUsage = (extension as X509KeyUsageExtension);

                    if (keyUsage != null && (keyUsage.KeyUsages & X509KeyUsageFlags.DigitalSignature) == X509KeyUsageFlags.None)
                        return false;

Which causes insidious bugs as it only occurs on iOS.

This is another "C# 6" language support that Xamarin.iOS claims to have since Mono 4, but doesn't.
Comment 1 Sebastien Pouliot 2015-09-06 12:01:31 UTC
Xamarin.iOS (like Xamarin.Mac and Xamarin.Android) does not ship a C# compiler. It use the C# compiler from Mono (OSX) or Microsoft (Windows) on the development computer.  By default the current stable 8.10.x should (on a Mac) be matched with the current Mono 4.0.x stable release.

You might have an outdated (it's possible to override those default installations) or it might be a bug in the compiler. Can you tell us the versions for all components ?

On a Mac the easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 Jahmai 2015-09-07 00:05:11 UTC
=== Xamarin Studio ===

Version 5.9.5 (build 10)
Installation UUID: 2d5e14a1-b37a-46b1-856b-616441f5424d
Runtime:
	Mono 4.0.3 ((detached/d6946b4)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400030020

=== Xamarin.Android ===

Not Installed

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.4.46 (Business Edition)
Hash: 2c66d2f
Branch: master
Build date: 2015-08-04 13:52:25-0400

=== Xamarin.Mac ===

Version: 2.0.2.111 (Starter Edition)

=== Build Information ===

Release ID: 509050010
Git revision: 48d16bc4f12ce3938964fc7c3d72fdc6887ad4ad
Build date: 2015-08-18 16:55:24-04
Xamarin addins: c2d51b360ad9f59e689046d47030df27de28f94a

=== Operating System ===

Mac OS X 10.10.0
Darwin Jyggalag-Mac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Marek Safar 2015-09-07 10:29:30 UTC
.
Comment 4 Marek Safar 2015-09-07 14:31:31 UTC
Fixed in master/e97227a53dc1a598f4e38de0fbd401dbe9ca7ca5 and mono-4.2/ec95d97fa66f85b480a55f0693d2db6e11618613