-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP fix some warnings on windows + fix 32 bits builds an incorrect use of size_t #7425
WIP fix some warnings on windows + fix 32 bits builds an incorrect use of size_t #7425
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a fix in this PR, but there are also a lot of unwanted changes. I'll move the fix to a separate branch with less clutter.
@@ -233,7 +233,7 @@ class bf_ref; | |||
class bf_iterator { | |||
uint64_t* data_area; | |||
uint64_t* first_word_ptr; | |||
size_t field_position; | |||
uint64_t field_position; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just a slowdown on 32 bit machines. The position is never too large for a 32 bit value.
@@ -303,11 +303,12 @@ class bf_iterator { | |||
auto first_word = first_word_ptr[0]; | |||
uint64_t mask = 0 - 1ULL; | |||
if (field_size < 64) { | |||
mask = static_cast<size_t>((1ULL << field_size) - 1); | |||
//we should never cast to size_t, but to uint64_t in order to support 32 bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not have a cast here at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in other PR I hope
value &= mask; | ||
} | ||
// zero out field in first word: | ||
auto first_word_mask = ~(mask << in_word_position); | ||
uint64_t first_word_mask = ~(mask << in_word_position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine. (but makes no difference).
@@ -391,14 +392,14 @@ inline void write_bitfield(uint64_t* data_area, size_t field_position, size_t wi | |||
|
|||
inline int64_t sign_extend_field_by_mask(size_t sign_mask, uint64_t value) | |||
{ | |||
uint64_t sign_extension = 0 - (value & sign_mask); | |||
uint64_t sign_extension = (uint64_t)0 - (value & sign_mask); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer 0ULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in other PR
@@ -174,13 +174,15 @@ class NodeHeader { | |||
|
|||
static size_t unsigned_to_num_bits(uint64_t value) | |||
{ | |||
return 1 + log2(static_cast<size_t>(value)); | |||
return 1 + static_cast<size_t>(std::log2(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this could be a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now in different PR
This PR #7427 contains the same fixes expressed in better way and less fuzzy.. |
const auto search_vector = populate(static_cast<int>(width), value); | ||
const auto field_count = num_fields_for_width(static_cast<int>(width)); | ||
const auto bit_count_pr_iteration = num_bits_for_width(static_cast<int>(width)); | ||
int64_t total_bit_count_left = static_cast<int64_t>((end - start) * width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would also be ok to use size_t for this ... perhaps that would allow for dropping a cast below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think total_bit_count_left
can become negative since we are taking out the amount of bits read per iteration. I'll address all the casts in a separate PR.. let's merge #7427
@@ -1285,6 +1285,20 @@ NONCONCURRENT_TEST(Test_basic_find_GT_value_greater_32bit) | |||
|
|||
#endif | |||
|
|||
ONLY(Test_ArrayInt_negative_nums) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to merge an ONLY test?
What, How & Why?
WIP. Contains some fixes for some warnings + uses
uint64_t
instead ofsize_t
in order to make compressed arrays compatible with 32 bits builds.☑️ ToDos
bindgen/spec.yml
, if public C++ API changed