Bug 314696 (MONO58475) - Incorrect long comparison
Summary: Incorrect long comparison
Status: RESOLVED MOVED
Alias: MONO58475
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Linux
: P3 - Medium : Normal
Target Milestone: V1
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-14 02:14 UTC by Nikolai Zhubr
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:37:40 UTC


---- Reported by s001@hotbox.ru 2004-05-13 19:14:43 MST ----

Description of Problem:
 C# miscompiles boolean expression

Steps to reproduce the problem:
 Compile and run the following test:
------------------------------------
using System;

class App {

    public static long BoolBugTest(long lVal, long rVal)
    {
            long rslt = lVal / rVal;
            long remV = lVal % rVal;
	    
            if (lVal < 0 != rVal < 0)
 {
        	System.Console.WriteLine("We get here if (lVal < 0 != rVal 
< 0). Lets see:");
        	System.Console.WriteLine(" lVal = " + 
System.Convert.ToString(lVal) +
        				", rVal = " + 
System.Convert.ToString(rVal));
		return 1;
	    }
	    return 0;
    }

    public static int Main(String[] args) {
	if (BoolBugTest(81,32) == 1) 
	    System.Console.WriteLine("Boolean evaluation bug detected.");
	else
	    System.Console.WriteLine("Test passed OK.");
	return 0;
    }

    
}

------------------------------------

Actual Results:
 Statement in "if (lVal < 0 != rVal < 0)...." is executed.

Expected Results:
 It shouldn't be!

How often does this happen? 
 Always (for this exact example)



---- Additional Comments From miguel@ximian.com 2004-05-13 19:29:13 MST ----

It works with Beta1.

It prints:

mono$ mono b.exe 
Test passed OK.

Setting to NEEDINFO



---- Additional Comments From s001@hotbox.ru 2004-05-13 19:53:13 MST ----

I do have beta 1 as well.
Ok, should I send you my test executable?
I'm not sure how can I track this down further.




---- Additional Comments From bmaurer@users.sf.net 2004-05-13 23:28:03 MST ----

Miguel, on CVS I have the same results as the reporter.



---- Additional Comments From bmaurer@users.sf.net 2004-05-13 23:30:55 MST ----

If i run the mcs binary on MS.net, it runs ok. If i compile with csc
and run on mono it fails ==> runtime.



---- Additional Comments From bmaurer@users.sf.net 2004-05-13 23:35:59 MST ----

using System;

class T {
	static int Main ()
	{
		long l = 1, ll = 2;
		
		if (l < 0 != ll < 0)
			return 1;
		
		return 0;
	}
}



---- Additional Comments From bmaurer@users.sf.net 2004-05-13 23:37:10 MST ----

Patrik, could this be caused by your patch?



---- Additional Comments From Patrik.Torstensson@intel.com 2004-05-14 04:52:36 MST ----

Test uses CLT that has the same problem as 54209 and is due to our 
long handling (we do branching in a basic block)

My patch just causes this example to be hit by the bug, sadly.

*** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO54209 ***


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>x86 linux 2.6.5, gcc 3.3.1</cf_op_sys_details>
This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"