Bug 16753 - Mcs compiles code that csc rejects (cast of negative numbers)
Summary: Mcs compiles code that csc rejects (cast of negative numbers)
Status: NEW
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 3.2.x
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-12-12 07:45 UTC by cmt.miniBill
Modified: 2013-12-12 07:46 UTC (History)
2 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 for Bug 16753 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description cmt.miniBill 2013-12-12 07:45:45 UTC
The following code compiles fine with mcs, but on the other hand is rejected by
csc with error CS0075

using System;

namespace Application
{
	public class EmptyClass<T>
	{
		public static implicit operator EmptyClass<T> (int i)
		{
			return new EmptyClass<T> ();
		}
	}

	public static class Program
	{
		static void Baz(EmptyClass<int?> arg)
		{
		}

		public static void Main ()
		{
			Baz ((EmptyClass<int?>)-1);
		}
	}
}
Comment 1 Marek Habersack 2013-12-12 07:46:39 UTC
Z:\tmp>csc ideone_bBybkB.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.33440
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
 
ideone_bBybkB.cs(21,9): error CS0075: To cast a negative value, you must enclose the value in parentheses
ideone_bBybkB.cs(21,10): error CS0118: 'Application.EmptyClass<int?>' is a 'type' but is used like a 'variable'