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)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

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'

Note You need to log in before you can comment on or make changes to this bug.