mattreecebentley / plf_colony

An unordered C++ data container providing fast iteration/insertion/erasure while maintaining pointer/iterator validity to non-erased elements regardless of insertions/erasures. Provides higher-performance than std:: library containers for high-modification scenarios with unordered data.
https://plflib.org/colony.htm
zlib License
398 stars 33 forks source link

Fix pedantic sign-conversion GCC warning #19

Closed 0x8000-0000 closed 5 years ago

0x8000-0000 commented 5 years ago

This fixes the following pedantic warning

 /home/florin/work/ftags/external/plf_colony/plf_colony.h:360:160: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
     PLF_COLONY_DEALLOCATE(uchar_allocator_type, (*this), reinterpret_cast<uchar_pointer_type>(elements), (capacity * sizeof(aligned_element_type)) + ((capacity + 1) * sizeof(skipfield_type)));                                                                                                                                                   
                                                                                                                                                         ~~~~~~~~~~^~~~
 /home/florin/work/ftags/external/plf_colony/plf_colony.h:170:163: note: in definition of macro ‘PLF_COLONY_DEALLOCATE’                                          
    #define PLF_COLONY_DEALLOCATE(the_allocator, allocator_instance, location, size)  std::allocator_traits<the_allocator>::deallocate(allocator_instance, location, size)
                                                                                                                                                          ^~~~
mattreecebentley commented 5 years ago

Thanks for this - I was not aware of this flag. However line 1426 is incorrect - *(new_location.skipfield_pointer) is of type skipfield_type so no recast is necessary. Having run the test suite with the flag enabled, it's also turned up a lot more errors than you've come across, so I will submit my own fix. Thanks once again-