[Mono-bugs] [Bug 79371][Nor] New - Compiler error when using "as" operator with int?

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Sep 11 17:33:22 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by michael at synthesyssolutions.com.

http://bugzilla.ximian.com/show_bug.cgi?id=79371

--- shadow/79371	2006-09-11 17:33:22.000000000 -0400
+++ shadow/79371.tmp.2986	2006-09-11 17:33:22.000000000 -0400
@@ -0,0 +1,62 @@
+Bug#: 79371
+Product: Mono: Compilers
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Debian Etch
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: michael at synthesyssolutions.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Compiler error when using "as" operator with int?
+
+Description of Problem:
+
+The following code compiles and executes using MS.NET, but not Mono:
+
+using System;
+
+public class NullableInt
+{
+         public static void Main()
+         {
+                 object x = null;
+
+                 int? y = x as int?;  /* Causes CS0077 */
+
+                 Console.WriteLine("y: '{0}'", y);
+                 Console.WriteLine("y.HasValue: '{0}'", y.HasValue);
+         }
+}
+
+Steps to reproduce the problem:
+1. Copy and paste code above into a source code file
+2. Attempt to compile source file with gmcs
+3. Receive compiler error CS0077
+
+Actual Results:
+
+test.cs(9,14): error CS0077: The as operator must be used with a 
+reference type (`int?' is a value type)
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+
+Successful compilation.  The program outputs the following using MS.NET:
+
+y: ''
+y.HasValue: 'False'
+
+How often does this happen? 
+
+Every time.
+
+Additional Information:
+
+Using svn TRUNK


More information about the mono-bugs mailing list