{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/30173","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/30173/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/30173/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/30173/events","html_url":"https://github.com/dotnet/corefx/issues/30173","id":329976329,"node_id":"MDU6SXNzdWUzMjk5NzYzMjk=","number":30173,"title":"Function erroneously returns null when compiled in release mode","user":{"login":"leecow","id":2212879,"node_id":"MDQ6VXNlcjIyMTI4Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2212879?v=4","gravatar_id":"","url":"https://api.github.com/users/leecow","html_url":"https://github.com/leecow","followers_url":"https://api.github.com/users/leecow/followers","following_url":"https://api.github.com/users/leecow/following{/other_user}","gists_url":"https://api.github.com/users/leecow/gists{/gist_id}","starred_url":"https://api.github.com/users/leecow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leecow/subscriptions","organizations_url":"https://api.github.com/users/leecow/orgs","repos_url":"https://api.github.com/users/leecow/repos","events_url":"https://api.github.com/users/leecow/events{/privacy}","received_events_url":"https://api.github.com/users/leecow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-06T18:11:17Z","updated_at":"2018-06-06T19:21:21Z","closed_at":null,"author_association":"MEMBER","body":"@jlwSL commented on [Wed Jun 06 2018](https://github.com/dotnet/core/issues/1663)\n\nI've discovered a bug that causes a function to return null even if every possible return value is non-null. The issue does not happen if the project is compiled in debug mode. Please see the code attached that reproduces this issue.\r\n\r\n```csharp\r\nusing System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace DotNetBug\r\n{\r\n    internal class Foo : IDisposable\r\n    {\r\n        public void Dispose()\r\n        {\r\n        }\r\n    }\r\n\r\n    class Program\r\n    {\r\n        public static string Aargh()\r\n        {\r\n            using (var foo = new Foo())\r\n            {\r\n                foreach (var i in new List<int>())\r\n                {\r\n                    try\r\n                    {\r\n                        Console.WriteLine(\"here\"); // This doesn't get printed\r\n                    }\r\n                    catch (Exception)\r\n                    {\r\n                        return \"wibble\";\r\n                    }\r\n                }\r\n                foreach (var i in new List<int>())\r\n                {\r\n                }\r\n            }\r\n        \r\n            return \"wobble\";\r\n        }\r\n\r\n        static void Main(string[] args)\r\n        {\r\n            Console.WriteLine(Aargh() == null);\r\n        }\r\n    }\r\n}\r\n```\r\nThe code above prints True.\r\n\r\nFor your information, my system details are below:\r\n\r\n```bash\r\n$ dotnet --info\r\n.NET Core SDK (reflecting any global.json):\r\n Version:   2.1.300\r\n Commit:    adab45bf0c\r\n\r\nRuntime Environment:\r\n OS Name:     centos\r\n OS Version:  7\r\n OS Platform: Linux\r\n RID:         centos.7-x64\r\n Base Path:   /usr/share/dotnet/sdk/2.1.300/\r\n\r\nHost (useful for support):\r\n  Version: 2.1.0\r\n  Commit:  caa7b7e2ba\r\n\r\n.NET Core SDKs installed:\r\n  2.1.300 [/usr/share/dotnet/sdk]\r\n\r\n.NET Core runtimes installed:\r\n  Microsoft.AspNetCore.All 2.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]\r\n  Microsoft.AspNetCore.App 2.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]\r\n  Microsoft.NETCore.App 2.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]\r\n\r\nTo install additional .NET Core runtimes or SDKs:\r\n  https://aka.ms/dotnet-download\r\n```\r\n\r\nI can also reproduce the issue on Windows with a slightly older SDK and Host version:\r\n```bash\r\n$ dotnet --info\r\n.NET Command Line Tools (2.1.201)\r\n\r\nProduct Information:\r\n Version:            2.1.201\r\n Commit SHA-1 hash:  7932dc6179\r\n\r\nRuntime Environment:\r\n OS Name:     Windows\r\n OS Version:  10.0.17134\r\n OS Platform: Windows\r\n RID:         win10-x64\r\n Base Path:   C:\\Program Files\\dotnet\\sdk\\2.1.201\\\r\n\r\nMicrosoft .NET Core Shared Framework Host\r\n\r\n  Version  : 2.0.7\r\n  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11\r\n```\r\n\r\nI tried to reproduce the issue targeting .NET Framework 4.5 and 4.6.1 and it worked correctly in both of those cases.\r\n\n\n---\n\n@leecow commented on [Wed Jun 06 2018](https://github.com/dotnet/core/issues/1663#issuecomment-395163136)\n\nI ran your code on Mac, Fedora 28 and a clean CentOS 7 image and all return `false`. Going to move this to the CoreFX to start. \n\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/395183992","html_url":"https://github.com/dotnet/corefx/issues/30173#issuecomment-395183992","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/30173","id":395183992,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTE4Mzk5Mg==","user":{"login":"0xd4d","id":1060731,"node_id":"MDQ6VXNlcjEwNjA3MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/1060731?v=4","gravatar_id":"","url":"https://api.github.com/users/0xd4d","html_url":"https://github.com/0xd4d","followers_url":"https://api.github.com/users/0xd4d/followers","following_url":"https://api.github.com/users/0xd4d/following{/other_user}","gists_url":"https://api.github.com/users/0xd4d/gists{/gist_id}","starred_url":"https://api.github.com/users/0xd4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xd4d/subscriptions","organizations_url":"https://api.github.com/users/0xd4d/orgs","repos_url":"https://api.github.com/users/0xd4d/repos","events_url":"https://api.github.com/users/0xd4d/events{/privacy}","received_events_url":"https://api.github.com/users/0xd4d/received_events","type":"User","site_admin":false},"created_at":"2018-06-06T19:21:21Z","updated_at":"2018-06-06T19:21:21Z","author_association":"NONE","body":"Looks like a jitter bug, so coreclr is a better repo.\r\n\r\n> I ran your code on Mac, Fedora 28 and a clean CentOS 7 image and all return false\r\n\r\nDid you try Release builds?"}}
{"actor":{"display_login":"0xd4d"}}