[Mono-bugs] [Bug 60095][Wis] Changed - (x & 0) == 0 is a constant true

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 12 Jun 2004 11:04:19 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=60095

--- shadow/60095	2004-06-12 05:44:37.000000000 -0400
+++ shadow/60095.tmp.2790	2004-06-12 11:04:19.000000000 -0400
@@ -1,23 +1,23 @@
 Bug#: 60095
 Product: Mono: Compilers
 Version: unspecified
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Wishlist
 Component: C#
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: gert.driesen@pandora.be               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: mcs does not report CS0162 (in warn level 4)
+Summary: (x & 0) == 0 is a constant true
 
 mcs does not report CS0162 (unreachable code detected) for the following 
 code :
 
 using System;
 using System.Reflection;
@@ -35,6 +35,25 @@
 }
 
 csc reports the following warning as the code in the if block can never 
 be executed :
 
 test.cs(12,4): warning CS0162: Unreachable code detected
+
+------- Additional Comments From bmaurer@users.sf.net  2004-06-12 11:04 -------
+Simpler test case, does not depend on warning.
+
+class T {
+	static int Main () {
+		int x = 0, y;
+		if ((x & 0) == 0)
+			y = 0;
+		return y;
+	}
+}
+
+On mcs this does not compile. (it considers y unassigned)
+
+CSC compiles it (because you always take the if statement).
+
+Does the spec define this behavior? Clearly MS is applying an algebaic
+ simplifier, do we need that?