{"action":"created","issue":{"url":"https://api.github.com/repos/chapel-lang/chapel/issues/8512","repository_url":"https://api.github.com/repos/chapel-lang/chapel","labels_url":"https://api.github.com/repos/chapel-lang/chapel/issues/8512/labels{/name}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/issues/8512/comments","events_url":"https://api.github.com/repos/chapel-lang/chapel/issues/8512/events","html_url":"https://github.com/chapel-lang/chapel/issues/8512","id":298369780,"number":8512,"title":"Need compiler error or implicit conversion for casting wide pointers to c_void_ptr","user":{"login":"LouisJenkinsCS","id":4269990,"avatar_url":"https://avatars2.githubusercontent.com/u/4269990?v=4","gravatar_id":"","url":"https://api.github.com/users/LouisJenkinsCS","html_url":"https://github.com/LouisJenkinsCS","followers_url":"https://api.github.com/users/LouisJenkinsCS/followers","following_url":"https://api.github.com/users/LouisJenkinsCS/following{/other_user}","gists_url":"https://api.github.com/users/LouisJenkinsCS/gists{/gist_id}","starred_url":"https://api.github.com/users/LouisJenkinsCS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LouisJenkinsCS/subscriptions","organizations_url":"https://api.github.com/users/LouisJenkinsCS/orgs","repos_url":"https://api.github.com/users/LouisJenkinsCS/repos","events_url":"https://api.github.com/users/LouisJenkinsCS/events{/privacy}","received_events_url":"https://api.github.com/users/LouisJenkinsCS/received_events","type":"User","site_admin":false},"labels":[{"id":496591117,"url":"https://api.github.com/repos/chapel-lang/chapel/labels/area:%20Compiler","name":"area: Compiler","color":"d4c5f9","default":false},{"id":112762316,"url":"https://api.github.com/repos/chapel-lang/chapel/labels/type:%20Bug","name":"type: Bug","color":"e99695","default":false},{"id":520459015,"url":"https://api.github.com/repos/chapel-lang/chapel/labels/user%20issue","name":"user issue","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-19T18:40:06Z","updated_at":"2018-02-20T21:24:22Z","closed_at":null,"author_association":"MEMBER","body":"When a wide pointer is cast to a `c_void_ptr` it produces an error in CodeGen that resembles this...\r\n\r\n```\r\nerror: cannot convert to a pointer type\r\n fn_chpl(((c_void_ptr)(tmp_chpl6)));\r\n ^~~~~~~\r\n```\r\n\r\nThis needs to either raise a compiler error or have it take the address portion and cast that to `c_void_ptr`. Note that this isn't really expected behavior and is very confusing for the user when the code that triggers such an error does not even make use of any locality at all. For this reason, I would think that if the user does cast it to a `c_void_ptr` and if the data is actually remote, it is the users fault (hence it should not result in a compiler error).\r\n\r\n**Minimum Working Example:**\r\n\r\n```chpl\r\nproc fn(f : c_void_ptr) {\r\n\twriteln(f);\r\n}\r\n\r\nclass Obj { var x : int; var y : int; var z : int;}\r\nvar obj : Obj = new Obj(1,2,3);\r\nfn(obj : c_void_ptr);\r\n```\r\n\r\n[TIO](https://tio.run/##TY1BDsIgFETXcoq/bJOyUHclnsEjNPgLivkBAqTVNr26SKuL7uZl8mbwIb2inH1wCNpWGlrAbnCm73wKNczsMAaTFJWqFmxhDEnGCNfbE2YYZIBXMYxNYoP3HqY/LGwlV4x28y5g1bim6ticmnOZLce/enctcv6gJnmPmXPrODmU9AU)\r\n\r\n**Proposed Change:**\r\n\r\nThis is a decent test I believe which should double as a good example for why I think it should handle the conversion implicitly. This will show two codegen errors, one for each cast of `a` and `b`. \r\n\r\n```chpl\r\n extern proc memmove(dest: c_void_ptr, const src: c_void_ptr, n: size_t);\r\nvar a = new object();\r\nvar b = new object();\r\nmemmove(a : c_void_ptr, b : c_void_ptr, c_sizeof(object));\r\n```\r\n[TIO](https://tio.run/##ZY1BCsIwEEX3nmKWDZgLtHiWMJlOtZJkQjJE6eGNiLqoLv@D/x5dMHPone/KJUEuQhA5Rmk8zFx1BHJN1tllLUcgSVWhFtrjNEJdN3ZqpkPDAggnSHwD8VcmHT7U/9FvCGHv8z@b3Esvy/C@GjP1/qAl4Ll2a5PYIIThCQ)\r\n"},"comment":{"url":"https://api.github.com/repos/chapel-lang/chapel/issues/comments/367124583","html_url":"https://github.com/chapel-lang/chapel/issues/8512#issuecomment-367124583","issue_url":"https://api.github.com/repos/chapel-lang/chapel/issues/8512","id":367124583,"user":{"login":"bradcray","id":7536222,"avatar_url":"https://avatars0.githubusercontent.com/u/7536222?v=4","gravatar_id":"","url":"https://api.github.com/users/bradcray","html_url":"https://github.com/bradcray","followers_url":"https://api.github.com/users/bradcray/followers","following_url":"https://api.github.com/users/bradcray/following{/other_user}","gists_url":"https://api.github.com/users/bradcray/gists{/gist_id}","starred_url":"https://api.github.com/users/bradcray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradcray/subscriptions","organizations_url":"https://api.github.com/users/bradcray/orgs","repos_url":"https://api.github.com/users/bradcray/repos","events_url":"https://api.github.com/users/bradcray/events{/privacy}","received_events_url":"https://api.github.com/users/bradcray/received_events","type":"User","site_admin":false},"created_at":"2018-02-20T21:24:22Z","updated_at":"2018-02-20T21:24:22Z","author_association":"OWNER","body":"I agree that this shouldn't result in a C compile-time error (nothing should).  If we're going to support the implicit conversion, I believe there should also be an on-by-default execution-time check to ensure that the wide pointer is local prior to dropping the locale information on the floor."}}
{"actor":{"display_login":"bradcray"}}