{"action":"closed","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/3149","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/3149/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/3149/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/3149/events","html_url":"https://github.com/dotnet/corefx/issues/3149","id":105735502,"number":3149,"title":"Expression compiler - Inconsistency with language specification","user":{"login":"bartdesmet","id":7324746,"avatar_url":"https://avatars.githubusercontent.com/u/7324746?v=3","gravatar_id":"","url":"https://api.github.com/users/bartdesmet","html_url":"https://github.com/bartdesmet","followers_url":"https://api.github.com/users/bartdesmet/followers","following_url":"https://api.github.com/users/bartdesmet/following{/other_user}","gists_url":"https://api.github.com/users/bartdesmet/gists{/gist_id}","starred_url":"https://api.github.com/users/bartdesmet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartdesmet/subscriptions","organizations_url":"https://api.github.com/users/bartdesmet/orgs","repos_url":"https://api.github.com/users/bartdesmet/repos","events_url":"https://api.github.com/users/bartdesmet/events{/privacy}","received_events_url":"https://api.github.com/users/bartdesmet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/bug","name":"bug","color":"207de5"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Linq.Expressions","name":"System.Linq.Expressions","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"VSadov","id":8218165,"avatar_url":"https://avatars.githubusercontent.com/u/8218165?v=3","gravatar_id":"","url":"https://api.github.com/users/VSadov","html_url":"https://github.com/VSadov","followers_url":"https://api.github.com/users/VSadov/followers","following_url":"https://api.github.com/users/VSadov/following{/other_user}","gists_url":"https://api.github.com/users/VSadov/gists{/gist_id}","starred_url":"https://api.github.com/users/VSadov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VSadov/subscriptions","organizations_url":"https://api.github.com/users/VSadov/orgs","repos_url":"https://api.github.com/users/VSadov/repos","events_url":"https://api.github.com/users/VSadov/events{/privacy}","received_events_url":"https://api.github.com/users/VSadov/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/4","html_url":"https://github.com/dotnet/corefx/milestones/1.0.0-rtm","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/4/labels","id":1248719,"number":4,"title":"1.0.0-rtm","description":"Q1 2016 (https://github.com/aspnet/Home/wiki/Roadmap)","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":229,"closed_issues":19,"state":"open","created_at":"2015-08-10T18:04:00Z","updated_at":"2015-10-14T08:58:27Z","due_on":"2016-03-31T07:00:00Z","closed_at":null},"comments":6,"created_at":"2015-09-10T05:37:54Z","updated_at":"2015-10-14T08:58:27Z","closed_at":"2015-10-14T08:58:27Z","body":"Section 7.9 of the C# language specification describes the number of bits to shift. It looks like this rule is not honored by the expression compiler which omits the `and` instruction to perform the mask, prior to performing the `shl` or `shr` instruction. The following repros the discrepancy:\r\n\r\nExpression&lt;Func&lt;long?, int?, long?&gt;&gt; e = (x, y) => x &lt;&lt; y;\r\n\r\nFunc&lt;long?, int?, long?&gt; f = (x, y) => x &lt;&lt; y;\r\nFunc&lt;long?, int?, long?&gt; g = e.Compile();\r\n\r\nvar c = f(-9223372036854775808, -2147483648);\r\nvar d = g(-9223372036854775808, -2147483648);\r\n\r\nConsole.WriteLine(c);\r\nConsole.WriteLine(d);\r\n\r\nNote that the implementation of the expression interpreter relies on C# compiled code fragments for << and >>, so this will cause a different result for .Compile() between frameworks that use the expression compiler versus those that use the interpreter."}}