boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
96 stars 116 forks source link

Wconversion warnings in vector.hpp #191

Closed Arghnews closed 2 years ago

Arghnews commented 2 years ago

Compiling the below file on Linux (clang10):

clang++ -std=c++17 a.cpp -I/my/path/to/boost/include -Wconversion

// a.cpp
#include "boost/container/small_vector.hpp"
int main() {
  boost::container::small_vector<int, 4> v;
  (void)(v.end());
  (void)(v.cend());
}

Results in warnings from this and this line in boost/container/vector.hpp

due to the comparison in unsigned and signed types.

These can both be fixed by changing the mentioned lines from it += this->m_holder.m_size; to it += static_cast<difference_type>(this->m_holder.m_size);

I'm consuming boost via the conan package manager, and it's not built as a system package, hence the warnings that would usually be suppressed.

Apologies if I'm missing something obvious as to why this is like this. Cheers.

igaztanaga commented 2 years ago

Thanks for the report. The commit:

https://github.com/boostorg/container/commit/dad2cb2d02aeccbf2d47eb0e18d73e52b9c51991

should have fixed all -Wconversion warnings.