Bug 314500 (MONO57747) - [Flow-analysis] We no do track definite assignment of expressions (12.3.3.23-26)
Summary: [Flow-analysis] We no do track definite assignment of expressions (12.3.3.23-26)
Status: RESOLVED FIXED
: 339392 370402 (view as bug list)
Alias: MONO57747
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-28 06:11 UTC by Martin Baulig
Modified: 2013-11-29 08:58 UTC (History)
2 users (show)

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


Attachments
sample program that fails illustrating bug (1.64 KB, text/plain)
2005-09-02 17:41 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:35:17 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".

Comment 1 Raja Harinath 2007-11-13 05:00:51 UTC
*** Bug 339392 has been marked as a duplicate of this bug. ***
Comment 2 Raja Harinath 2008-03-31 06:11:30 UTC
*** Bug 370402 has been marked as a duplicate of this bug. ***
Comment 3 Raja Harinath 2008-03-31 06:17:13 UTC
*** Bug 370414 has been marked as a duplicate of this bug. ***
Comment 4 Raja Harinath 2008-03-31 06:19:29 UTC
(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.
Comment 6 Susanne Oberhauser-Hirschoff 2011-07-20 12:30:04 UTC
Reassigning to Miguel to drive further resolution...
Comment 7 Marek Safar 2013-11-29 08:58:19 UTC
Fixed