The following code in a console app:
> Console.WriteLine (IntPtr.Size + " " + (int)double.MaxValue);
> Console.WriteLine (IntPtr.Size + " " + (int)Math.Floor (double.MaxValue));
I noticed this after the System.Timers.Timer source from MS referencesource was imported, as a test started failing on amd64 (see http://wrench.mono-project.com/Wrench/WebServices/Download.aspx?workfile_id=3679509 for an example on Wrench).
Thanks to @davidkarlas and @alexrp for their help.
I can also reproduce on OSX and Mono for Windows.
> C:\dev\mono\msvc\x64\bin>mono.exe Program.exe
> 8 -2147483648
> 8 0
Fixed in mono master 6cf56cbb2f3a95bcacf23f891830ae45a0ebdfa3.
I can confirm the runtime bug is fixed but I still see some different behaviour with mcs vs. csc, even when running mcs with a Mono with this fix applied.
Looking into it.
So after some research, me and @akoeplinger concluded that there's a bug in csc.exe when doing double-to-int narrowing conversions. mcs is doing the right thing and Roslyn also seems to have fixed it since:
> <akoeplinger> I tested with roslyn 0.6.4 as used on dotnetfiddle and it does ldc.i4.0, but the roslyn used on another site generates the same as mcs
I don't think we are shipping 64-bit X86 runtimes in either Windows or OSX so that's why you can't see the option under OSX. And under Windows it must be using the .NET one.
You'll have to compile a 64-bit Mono if you really want to reproduce the fix since it's 64-bit specific.
Thank you very much Sebastien.
With the help of comment 7 I am able to reproduce this issue.
To verify this issue, I have checked this issue with following builds:
Mac OS X 10.10.0
Xamarin Studio: 5.8 (build 624)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000068
Xcode 6.1 (6604)
Xamarin.iOS: 184.108.40.206 (Business Edition)
=== Build Information ===
Release ID: 508000624
Git revision: fbedf37530cbbf01a75c4cc95557944aa8996aaa
Build date: 2015-01-30 07:52:28-05
Xamarin addins: cb32b8c2c23d061713c5abe206b8ad07723aa77e
Observations: When I run the test case mentioned in bug description with XI. The output is :
This issue has been fixed. Hence I am closing this issue.