Bug 29276 - Use of possibly unassigned field for sub struct on out parameter
Summary: Use of possibly unassigned field for sub struct on out parameter
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.12.0
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2015-04-21 13:33 UTC by Jonathan Marler
Modified: 2015-07-21 13:15 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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

System 2 Info

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
Comment 1 Jonathan Marler 2015-04-21 13:36:55 UTC
P.S. This error is NOT reproducible on Mono version 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
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