Bug 9186 - ulong/float comparison miscompiled on 64bit Macs
Summary: ulong/float comparison miscompiled on 64bit Macs
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-01-02 11:38 UTC by Marek Safar
Modified: 2013-01-03 12:54 UTC (History)
3 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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Marek Safar 2013-01-02 11:38:33 UTC
float b = 0f;
            if (b < ulong.MaxValue)
                Console.WriteLine ("hit");

"hit" is never hit when mono is compiled as 64 bit on mac
Comment 1 Zoltan Varga 2013-01-03 00:04:22 UTC
I can't reproduce this. Can you attach a complete testcase plus the generated .exe ?
Comment 2 Marek Safar 2013-01-03 11:33:24 UTC
This is actually AOT issue

class C
{
	public static void Main ()
	{
		ulong ul = ulong.MaxValue;
		System.Console.WriteLine ((float) ul);
	}
}

When compiled and run with mono JIT I get
1.844674E+19
when using --aot I get
NaN

My log

mono test-mcs.exe
1.844674E+19
[mono] ~/git/mono/mcs/mcs$ mono --aot test-mcs.exe
Mono Ahead of Time compiler - compiling assembly /Users/marek/git/mono/mcs/mcs/test-mcs.exe
Code: 163 Info: 5 Ex Info: 8 Unwind Info: 17 Class Info: 34 PLT: 3 GOT Info: 17 GOT: 28 Offsets: 48
Compiled: 2/2 (100%), No GOT slots: 1 (50%), Direct calls: 0 (100%)
Executing the native assembler: as -arch i386 -W  -o /var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/mono_aot_1M2W4C.o /var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/mono_aot_1M2W4C
Executing the native linker: gcc -m32 -dynamiclib -o /Users/marek/git/mono/mcs/mcs/test-mcs.exe.dylib.tmp /var/folders/zw/_2mb6txx19b1c3g9ls4mwngr0000gn/T/mono_aot_1M2W4C.o
Generating debug symbols: dsymutil /Users/marek/git/mono/mcs/mcs/test-mcs.exe.dylib
JIT time: 0 ms, Generation time: 0 ms, Assembly+Link time: 32 ms.
[mono] ~/git/mono/mcs/mcs$ mono test-mcs.exe
NaN
Comment 3 Zoltan Varga 2013-01-03 12:54:24 UTC
Fixed in master.