{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/4362","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/4362/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/4362/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/4362/events","html_url":"https://github.com/dotnet/roslyn/issues/4362","id":99286289,"number":4362,"title":"Warnings about unassigned fields in structs used with pointers","user":{"login":"MichalStrehovsky","id":13110571,"avatar_url":"https://avatars.githubusercontent.com/u/13110571?v=3","gravatar_id":"","url":"https://api.github.com/users/MichalStrehovsky","html_url":"https://github.com/MichalStrehovsky","followers_url":"https://api.github.com/users/MichalStrehovsky/followers","following_url":"https://api.github.com/users/MichalStrehovsky/following{/other_user}","gists_url":"https://api.github.com/users/MichalStrehovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalStrehovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalStrehovsky/subscriptions","organizations_url":"https://api.github.com/users/MichalStrehovsky/orgs","repos_url":"https://api.github.com/users/MichalStrehovsky/repos","events_url":"https://api.github.com/users/MichalStrehovsky/events{/privacy}","received_events_url":"https://api.github.com/users/MichalStrehovsky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-05T19:56:42Z","updated_at":"2015-08-05T23:37:42Z","closed_at":null,"body":"```csharp\r\nstruct Foo\r\n{\r\n    public uint Bar;\r\n}\r\n\r\nstatic void Main()\r\n{\r\n    unsafe\r\n    {\r\n        uint x = 42;\r\n        Foo* f = (Foo*)&x;\r\n        Console.WriteLine(f->Bar);\r\n    }\r\n}\r\n```\r\n\r\nThe above code will issue a warning: `warning CS0649: Field 'Program.Foo.Bar' is never assigned to, and will always have its default value 0`. This is obviously not true because the program will print `42`.\r\n\r\nThe warning goes away if I put `StructLayout(LayoutKind.Sequential)` on the struct, but since sequential layout is the C# default, the StructLayout attribute should be a no-op. Apparently, it isn't."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/128184122","html_url":"https://github.com/dotnet/roslyn/issues/4362#issuecomment-128184122","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/4362","id":128184122,"user":{"login":"Janiels","id":7887810,"avatar_url":"https://avatars.githubusercontent.com/u/7887810?v=3","gravatar_id":"","url":"https://api.github.com/users/Janiels","html_url":"https://github.com/Janiels","followers_url":"https://api.github.com/users/Janiels/followers","following_url":"https://api.github.com/users/Janiels/following{/other_user}","gists_url":"https://api.github.com/users/Janiels/gists{/gist_id}","starred_url":"https://api.github.com/users/Janiels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Janiels/subscriptions","organizations_url":"https://api.github.com/users/Janiels/orgs","repos_url":"https://api.github.com/users/Janiels/repos","events_url":"https://api.github.com/users/Janiels/events{/privacy}","received_events_url":"https://api.github.com/users/Janiels/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T23:37:42Z","updated_at":"2015-08-05T23:37:42Z","body":"I was surprised that the default layout applied by the C# compiler is sequential. Is this documented somewhere in the C# spec? I haven't been able to find it."}}