Skip to content

Fix serialization of native integral types - #11

Open
swdaa wants to merge 1 commit into
rwindegger:mainfrom
swdaa:fix/native-integral-types
Open

Fix serialization of native integral types#11
swdaa wants to merge 1 commit into
rwindegger:mainfrom
swdaa:fix/native-integral-types

Conversation

@swdaa

@swdaa swdaa commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fix serialization of native integral types that are not aliases of the
fixed-width integer types handled by the existing overloads.

On macOS, std::size_t is unsigned long, while std::uint64_t may be
a different underlying type. As a result, std::size_t could fall through
to the custom-object overload and attempt to call value.pack() /
value.unpack().

This change routes otherwise-unhandled integral types through the existing
fixed-width integer serialization overloads and excludes integral types from
the custom-object fallback.

Testing

  • Built the project with Clang on macOS
  • Existing std::vector<std::size_t> array test now compiles
  • All tests pass with ctest --test-dir build --output-on-failure

Copilot AI lite review requested due to automatic review settings August 9, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes MsgPack serialization for native integral types (e.g., std::size_t) whose underlying type may not be one of the fixed-width integer typedefs, preventing them from incorrectly falling into the custom-object pack()/unpack() fallback.

Changes:

  • Added pack_type / unpack_type overloads to route otherwise-unhandled std::integral types through existing fixed-width integer serialization.
  • Excluded integral types from the custom-object fallback overloads so they don’t attempt value.pack() / value.unpack().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +754 to +764
void unpack_type(T &value) {
if constexpr (std::signed_integral<T>) {
std::int64_t tmp{};
unpack_type(tmp);
value = static_cast<T>(tmp);
} else {
std::uint64_t tmp{};
unpack_type(tmp);
value = static_cast<T>(tmp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants