Skip to content

Commit

Permalink
Fix -Wsign-compare warnings in variant.hpp; also catches the case whe…
Browse files Browse the repository at this point in the history
…n `which` is negative
  • Loading branch information
pdimov committed Apr 10, 2024
1 parent a32906b commit 2a29731
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/boost/serialization/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void load(
int which;
typedef typename boost::variant<Types...>::types types;
ar >> BOOST_SERIALIZATION_NVP(which);
if(which >= sizeof...(Types)){
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
Expand All @@ -238,7 +238,7 @@ void load(
int which;
typedef typename boost::variant<Types...>::types types;
ar >> BOOST_SERIALIZATION_NVP(which);
if(which >= sizeof...(Types)){
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
Expand Down

0 comments on commit 2a29731

Please sign in to comment.