{"action":"closed","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26203","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26203/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26203/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26203/events","html_url":"https://github.com/rust-lang/rust/issues/26203","id":87190932,"number":26203,"title":"Casting a function pointer to a non-machine integer type results in an LLVM Error","user":{"login":"Aatch","id":342416,"avatar_url":"https://avatars.githubusercontent.com/u/342416?v=3","gravatar_id":"","url":"https://api.github.com/users/Aatch","html_url":"https://github.com/Aatch","followers_url":"https://api.github.com/users/Aatch/followers","following_url":"https://api.github.com/users/Aatch/following{/other_user}","gists_url":"https://api.github.com/users/Aatch/gists{/gist_id}","starred_url":"https://api.github.com/users/Aatch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aatch/subscriptions","organizations_url":"https://api.github.com/users/Aatch/orgs","repos_url":"https://api.github.com/users/Aatch/repos","events_url":"https://api.github.com/users/Aatch/events{/privacy}","received_events_url":"https://api.github.com/users/Aatch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-11T03:02:24Z","updated_at":"2015-06-11T03:12:54Z","closed_at":"2015-06-11T03:12:54Z","body":"This code produces the error `LLVM ERROR: expected relocatable expression`:\r\n\r\n```rust\r\nfn foo(_: i32) { }\r\n\r\nfn main() {\r\n    let x : u32 = foo as u32;\r\n}\r\n```\r\n\r\nI'd expect this to work on a 32-bit platform though. I'd argue this is technically LLVM's bug, since casting a regular raw pointer works just fine.\r\n\r\nThis does however raise the point of whether or not allowing casting to non-machine integers from pointers should be allowed. The case that uncovered this bug was actually supposed to be casting the return value of the function.\r\n\r\nThe fix for this should be fairly simple, if we decide to accept the behaviour (either out of backwards compability concerns or otherwise), just run all casts like this through the machine integer first.\r\n\r\n/cc @rust-lang/compiler @rust-lang/lang"}}