Bugzilla – Bug 314500
[Flow-analysis] We no do track definite assignment of expressions (12.3.3.23-26)
Last modified: 2013-11-29 08:58:19 UTC
---- Reported by martin@ximian.com 2004-04-27 23:11:11 MST ---- We did not implement the definite assignment rules wrt. `&&' and `||' expressions. The testcases are from https://bugzilla.novell.com/show_bug.cgi?id=MONO41787. Setting priority to wishlist, severity = 40. ---- Additional Comments From martin@ximian.com 2004-04-27 23:11:20 MST ---- using System; class Test14 { static void F(bool b, int i) { int x; if (b && (x = i) >= 0) // OK: 'x' definitely assigned Console.WriteLine(x); else // Error: 'x' not definitely assigned Console.WriteLine(x); } public static void Main() { F(true,5); F(false,7); } } ---- Additional Comments From martin@ximian.com 2004-04-27 23:11:44 MST ---- using System; class Test15 { static void F(bool b, int i) { int x; if (b || (x = i) >= 0) // Error: 'x' not definitely assigned Console.WriteLine(x); else // OK: 'x' definitely assigned Console.WriteLine(x); } public static void Main() { F(true,5); F(false,7); } } ---- Additional Comments From martin@ximian.com 2004-04-27 23:12:54 MST ---- using System; class Test5 { static void F(bool b) { int x; while (b?true:true); // OK: 'x' definitely assigned Console.WriteLine(x); } public static void Main() { F(true); } } ---- Additional Comments From martin@ximian.com 2004-04-27 23:14:33 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO41787 has been marked as a duplicate of this bug. *** ---- Additional Comments From martin@ximian.com 2004-05-23 15:39:07 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO58405 has been marked as a duplicate of this bug. *** ---- Additional Comments From martin@ximian.com 2005-05-10 13:32:45 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO74895 has been marked as a duplicate of this bug. *** ---- Additional Comments From bmaurer@users.sf.net 2005-05-19 21:19:33 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO74894 has been marked as a duplicate of this bug. *** ---- Additional Comments From martin@ximian.com 2005-05-20 04:23:42 MST ---- Maybe I should have a look at this someday .... ---- Additional Comments From atsushi@ximian.com 2005-09-01 05:42:21 MST ---- Another set of examples that does not use if-statement: -------- class Test { public int AbsOK (bool b, int i) { int x; int y = true ? (x = i) : (x = i); return x; } public int FooOK (bool b, int i) { int x; int y = true ? (x = i) : 0; return x; } public int BarOK (bool b, int i) { int x; int y = false ? 0 : (x = i); return x; } public int FooNG1 (bool b, int i) { int x; int y = true ? 0 : (x = i); return x; } public int BarNG1 (bool b, int i) { int x; int y = false ? (x = i) : 0; return x; } public int FooNG2 (bool b, int i) { int x; int y = b ? (x = i) : 0; return x; } public int BarNG2 (bool b, int i) { int x; int y = b ? 0 : (x = i); return x; } } expected output: 57747z.cs(28,10): error CS0165: Use of unassigned local variable 'x' 57747z.cs(35,10): error CS0165: Use of unassigned local variable 'x' 57747z.cs(42,10): error CS0165: Use of unassigned local variable 'x' 57747z.cs(49,10): error CS0165: Use of unassigned local variable 'x' ---- Additional Comments From Paul.Nelson@jmp.com 2005-09-02 10:41:51 MST ---- Created an attachment (id=165936) sample program that fails illustrating bug ---- Additional Comments From Paul.Nelson@jmp.com 2005-09-02 10:47:32 MST ---- The attachment I added mcsbug.cs is a test case of the bug I found when I was trying to compile the PDF creation library itextsharp from sourceforge.net. This was the only error reported by the compiler when trying to build the itextsharp.dll. However, even by fixing the itextsharp source for this bug, mcs does not generate a working itextsharp.dll, where the Visual Studio Compiled one does function, (and functions on linux under mono). itextsharp-3.0.7 ---- Additional Comments From martin@ximian.com 2005-09-02 11:09:34 MST ---- The priority was like it was for a reason. This bug blocked bug(s) 78001. Imported an attachment (id=165936) Unknown operating system unknown. Setting to default OS "Other".
*** Bug 339392 has been marked as a duplicate of this bug. ***
*** Bug 370402 has been marked as a duplicate of this bug. ***
*** Bug 370414 has been marked as a duplicate of this bug. ***
(In reply to comment #3 from Raja Harinath) > *** Bug 370414 has been marked as a duplicate of this bug. *** Ignore this. It was an operator error.
Reassigning to Miguel to drive further resolution...
Fixed