[Mono-bugs] [Bug 76678][Nor] New - mcs reports CS0168 instead of
CS0219 for variable assigned in if block
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sat Nov 12 05:13:09 EST 2005
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 gert.driesen at pandora.be.
http://bugzilla.ximian.com/show_bug.cgi?id=76678
--- shadow/76678 2005-11-12 05:13:09.000000000 -0500
+++ shadow/76678.tmp.26872 2005-11-12 05:13:09.000000000 -0500
@@ -0,0 +1,71 @@
+Bug#: 76678
+Product: Mono: Compilers
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: gert.driesen at pandora.be
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs reports CS0168 instead of CS0219 for variable assigned in if block
+
+mcs reports warning CS0168 (variable is declared by never used) instead
+of CS0219 (variable is assigned but its value is never used), if a
+variable is assigned in an if block only.
+
+Note: the correct warning is reported if the enclosing method returns a
+value (not void).
+
+To reproduce, compile the following code snippet:
+
+public class Test
+{
+ public static void Main ()
+ {
+ FixVolatileData (1);
+ FixVolatileData2 (1);
+ }
+
+ private static void FixVolatileData(int flags)
+ {
+ object forceCreation;
+
+ if (flags > 0) {
+ forceCreation = "";
+ }
+ }
+
+ private static string FixVolatileData2(int flags)
+ {
+ object forceCreation;
+
+ if (flags > 0) {
+ forceCreation = "";
+ }
+
+ return string.Empty;
+ }
+}
+
+Actual result:
+
+test.cs(13,10): warning CS0168: The variable 'forceCreation' is declared
+but never used
+test.cs(23,10): warning CS0219: The variable 'forceCreation' is assigned
+but its value is never used
+
+Note that the correct warning is output for the usage of 'forceCreation'
+in the FixVolatileData2 method.
+
+Expected result:
+test.cs(13,10): warning CS0219: The variable 'forceCreation' is assigned
+but its value is never used
+test.cs(23,10): warning CS0219: The variable 'forceCreation' is assigned
+but its value is never used
More information about the mono-bugs
mailing list