Bug 29276

Summary: Use of possibly unassigned field for sub struct on out parameter
Product: [Mono] Compilers Reporter: Jonathan Marler <johnnymarler>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: fandabu, johnnymarler, mono-bugs+mono
Priority: ---    
Version: 3.12.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Jonathan Marler 2015-04-21 13:33:08 UTC
bash-4.1$ mcs UnassignedCompilerBug.cs
UnassignedCompilerBug.cs(35): error CS0170: Use of possibly unassigned field `location'
Compilation failed: 1 error(s), 0 warnings

Expected: code to compile with no errors or warnings

--------------------------------------------------
using System;

public struct Location
{
    public int x;
    public int y;
}
public struct LocationWrapper
{
    public Location location;
}
class Program
{
    static void Main(String[] args)
    {
    }
    // OK
    public static void Test(out Location location)
    {
        location.x = 0;
        location.y = location.x;
    }
    // OK
    public static void Test(LocationWrapper member)
    {
        member.location.x = 0;
        member.location.y = member.location.x;
    }
    // error CS0170: Use of possibly unassigned field `location'
    public static void Test(out LocationWrapper member)
    {
        member.location.x = 0;
        member.location.y = member.location.x;
    }
}
-----------------------------------------



System 1 Info
-------------------------------------------------------------------
Windows 7 64-bit

C:\Temp\monobug\monobug>mcs --version
Mono C# compiler version 3.12.1.0


System 2 Info
-------------------------------------------------------------------
Redhat

bash-4.1$ uname -a
Linux hpblsv52.boi.hp.com 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

bash-4.1$ mcs --version
Mono C# compiler version 3.0.3.0
Comment 1 Jonathan Marler 2015-04-21 13:36:55 UTC
P.S. This error is NOT reproducible on Mono version 2.10.0.0 or any of the Visual Studio compilers that were tested.
Comment 2 Marek Safar 2015-05-07 12:26:07 UTC
Fixed in master
Comment 3 Jonathan Marler 2015-05-07 18:18:12 UTC
Marek, were you able to reproduce this issue?  Can you confirm it occurs on or before the released compiler version 3.12.1.0?
Comment 4 Marek Safar 2015-05-08 03:13:03 UTC
I could reproduce the issue and as I noted before it was fixed in mono master yesterday