Skip to content

Commit

Permalink
Make UnpackerErrCategory an unique category
Browse files Browse the repository at this point in the history
This is a problem in Release compilation where the
theUnpackerErrCategory variable is optimized and created on each
compilation unit, and then the error_handling.cpp test fails in:

  REQUIRE(ec == msgpack::UnpackerError::OutOfRange);

Because the category is different on each compilation unit.
  • Loading branch information
dacap committed Aug 9, 2022
1 parent 515ad0c commit ea0d3c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions msgpack/include/msgpack/msgpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ struct UnpackerErrCategory : public std::error_category {
return "(unrecognized error)";
}
};
};

const UnpackerErrCategory theUnpackerErrCategory{};
};

inline
std::error_code make_error_code(msgpack::UnpackerError e) {
static UnpackerErrCategory theUnpackerErrCategory;
return {static_cast<int>(e), theUnpackerErrCategory};
}
}
Expand Down

0 comments on commit ea0d3c4

Please sign in to comment.