Bug 19702

Summary: Null coalescing expression evaluated twice with nullable return type.
Product: [Mono] Compilers Reporter: Miles <miles.parfitt+xamarin>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: mono-bugs+mono, mono-bugs+runtime, vargaz
Priority: ---    
Version: 3.4.0   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Miles 2014-05-12 19:20:27 UTC
In the below code, the Left() method is incorrectly executed twice.  The issue only appears to be happening for nullable types.

    class MainClass
        private static int _count = 1;

        public static void Main(string[] args)
            var x = Left() ?? Right();

        private static DateTime? Left()
            Console.Out.WriteLine("Execution " + _count++);
            return DateTime.Now;

        private static DateTime? Right()
            return DateTime.Now;
Comment 1 Zoltan Varga 2014-05-13 12:34:29 UTC
-> mcs.
Comment 2 Marek Safar 2014-05-22 02:39:04 UTC
Fixed in master