{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/873","repository_url":"https://api.github.com/repos/dotnet/csharplang","labels_url":"https://api.github.com/repos/dotnet/csharplang/issues/873/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/csharplang/issues/873/comments","events_url":"https://api.github.com/repos/dotnet/csharplang/issues/873/events","html_url":"https://github.com/dotnet/csharplang/issues/873","id":254780101,"number":873,"title":"Is this a bug?","user":{"login":"qaqz111","id":3367034,"avatar_url":"https://avatars0.githubusercontent.com/u/3367034?v=4","gravatar_id":"","url":"https://api.github.com/users/qaqz111","html_url":"https://github.com/qaqz111","followers_url":"https://api.github.com/users/qaqz111/followers","following_url":"https://api.github.com/users/qaqz111/following{/other_user}","gists_url":"https://api.github.com/users/qaqz111/gists{/gist_id}","starred_url":"https://api.github.com/users/qaqz111/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qaqz111/subscriptions","organizations_url":"https://api.github.com/users/qaqz111/orgs","repos_url":"https://api.github.com/users/qaqz111/repos","events_url":"https://api.github.com/users/qaqz111/events{/privacy}","received_events_url":"https://api.github.com/users/qaqz111/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-09-02T01:15:17Z","updated_at":"2017-09-02T02:48:45Z","closed_at":null,"author_association":"NONE","body":"```C#\r\nprivate int x;\r\n[Test]\r\npublic void Foo()\r\n{\r\n    x = 16;\r\n    x -= Bar(4);\r\n    Console.WriteLine(x); //-> 12\r\n}\r\nprivate int Bar(int y)\r\n{\r\n    x -= y;\r\n    return y;\r\n}\r\n```\r\nThe IL of release compile:\r\n```IL\r\nIL_0000: ldarg.0\r\nIL_0001: ldc.i4.s 16\r\nIL_0003: stfld int32 NUnitTest.Test1::x\r\nIL_0008: ldarg.0\r\nIL_0009: ldarg.0\r\nIL_000a: ldfld int32 NUnitTest.Test1::x //<- old value pushed onto stack\r\nIL_000f: ldarg.0\r\nIL_0010: ldc.i4.4\r\nIL_0011: call instance int32 NUnitTest.Test1::Bar(int32)\r\nIL_0016: sub\r\nIL_0017: stfld int32 NUnitTest.Test1::x\r\nIL_001c: ldarg.0\r\nIL_001d: ldfld int32 NUnitTest.Test1::x\r\nIL_0022: call void [mscorlib]System.Console::WriteLine(int32)\r\nIL_0027: ret\r\n```\r\nThe point is `IL_000a`, **current** value of `x` is pushed onto stack, but next call changed the value of `x`, the previous current value becomes **old** value."},"comment":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/comments/326717404","html_url":"https://github.com/dotnet/csharplang/issues/873#issuecomment-326717404","issue_url":"https://api.github.com/repos/dotnet/csharplang/issues/873","id":326717404,"user":{"login":"jnm2","id":8040367,"avatar_url":"https://avatars2.githubusercontent.com/u/8040367?v=4","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"created_at":"2017-09-02T02:48:45Z","updated_at":"2017-09-02T02:48:45Z","author_association":"CONTRIBUTOR","body":"You're right, VS2017's C++ compiler does return 8, unlike ideone which probably uses gcc.\r\n\r\nIn general, I try not to write code that is dependent on arcane details like this. :D"}}
{"actor":{"display_login":"jnm2"}}