{"action":"closed","issue":{"url":"https://api.github.com/repos/RoaringBitmap/CRoaring/issues/164","repository_url":"https://api.github.com/repos/RoaringBitmap/CRoaring","labels_url":"https://api.github.com/repos/RoaringBitmap/CRoaring/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/RoaringBitmap/CRoaring/issues/164/comments","events_url":"https://api.github.com/repos/RoaringBitmap/CRoaring/issues/164/events","html_url":"https://github.com/RoaringBitmap/CRoaring/issues/164","id":338604015,"node_id":"MDU6SXNzdWUzMzg2MDQwMTU=","number":164,"title":"VS 2017: Warning on size_t conversion","user":{"login":"madscientist","id":109636,"node_id":"MDQ6VXNlcjEwOTYzNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109636?v=4","gravatar_id":"","url":"https://api.github.com/users/madscientist","html_url":"https://github.com/madscientist","followers_url":"https://api.github.com/users/madscientist/followers","following_url":"https://api.github.com/users/madscientist/following{/other_user}","gists_url":"https://api.github.com/users/madscientist/gists{/gist_id}","starred_url":"https://api.github.com/users/madscientist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madscientist/subscriptions","organizations_url":"https://api.github.com/users/madscientist/orgs","repos_url":"https://api.github.com/users/madscientist/repos","events_url":"https://api.github.com/users/madscientist/events{/privacy}","received_events_url":"https://api.github.com/users/madscientist/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"madscientist","id":109636,"node_id":"MDQ6VXNlcjEwOTYzNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109636?v=4","gravatar_id":"","url":"https://api.github.com/users/madscientist","html_url":"https://github.com/madscientist","followers_url":"https://api.github.com/users/madscientist/followers","following_url":"https://api.github.com/users/madscientist/following{/other_user}","gists_url":"https://api.github.com/users/madscientist/gists{/gist_id}","starred_url":"https://api.github.com/users/madscientist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madscientist/subscriptions","organizations_url":"https://api.github.com/users/madscientist/orgs","repos_url":"https://api.github.com/users/madscientist/repos","events_url":"https://api.github.com/users/madscientist/events{/privacy}","received_events_url":"https://api.github.com/users/madscientist/received_events","type":"User","site_admin":false},"assignees":[{"login":"madscientist","id":109636,"node_id":"MDQ6VXNlcjEwOTYzNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109636?v=4","gravatar_id":"","url":"https://api.github.com/users/madscientist","html_url":"https://github.com/madscientist","followers_url":"https://api.github.com/users/madscientist/followers","following_url":"https://api.github.com/users/madscientist/following{/other_user}","gists_url":"https://api.github.com/users/madscientist/gists{/gist_id}","starred_url":"https://api.github.com/users/madscientist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madscientist/subscriptions","organizations_url":"https://api.github.com/users/madscientist/orgs","repos_url":"https://api.github.com/users/madscientist/repos","events_url":"https://api.github.com/users/madscientist/events{/privacy}","received_events_url":"https://api.github.com/users/madscientist/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-07-05T14:41:05Z","updated_at":"2018-07-06T20:31:30Z","closed_at":"2018-07-06T20:31:30Z","author_association":"CONTRIBUTOR","body":"You don't seem too concerned about warnings but I'll continue to file these issues; if you elect to not solve them then I'll just keep the changes locally.\r\n\r\nVisual Studio 2017 (at least-probably 2015 as well) complains about type mismatches:\r\n```\r\n    23>c:\\users\\build\\\\foundation\\croaring\\roaring.c(4857): warning C4267: '=': conversion from 'size_t' to 'int32_t', possible loss of data\r\n```\r\nThis is the amalgamation so the line numbers won't mean much to you, but it's invoking roaring_array.c:ralloc_array() which takes `size_t new_capacity`, but most callers are passing type `int32_t` (I'm not sure why we elect to use signed values for size?  I get why 32bit values are preferred but why signed?)\r\n\r\nThe patch below will fix this:\r\n```\r\n--- a/src/roaring_array.c\r\n+++ b/src/roaring_array.c\r\n@@ -27,7 +27,7 @@ extern inline void ra_set_container_at_index(const roaring_array_t *ra,\r\n \r\n #define INITIAL_CAPACITY 4\r\n \r\n-static bool realloc_array(roaring_array_t *ra, size_t new_capacity) {\r\n+static bool realloc_array(roaring_array_t *ra, int32_t new_capacity) {\r\n     // because we combine the allocations, it is not possible to use realloc\r\n     /*ra->keys =\r\n     (uint16_t *)realloc(ra->keys, sizeof(uint16_t) * new_capacity);\r\n@@ -207,7 +207,7 @@ void ra_clear(roaring_array_t *ra) {\r\n bool extend_array(roaring_array_t *ra, int32_t k) {\r\n     int32_t desired_size = ra->size + k;\r\n     if (desired_size > ra->allocation_size) {\r\n-        size_t new_capacity =\r\n+        int32_t new_capacity =\r\n             (ra->size < 1024) ? 2 * desired_size : 5 * desired_size / 4;\r\n \r\n         return realloc_array(ra, new_capacity);\r\n```"}}
{"actor":{"display_login":"lemire"}}