Bug 33723 - Null propagation operator produces incorrect IL
Summary: Null propagation operator produces incorrect IL
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: 4.2.0 (C6)
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-09-06 08:17 UTC by Jahmai
Modified: 2015-09-07 14:31 UTC (History)
5 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 FIXED

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