-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packed and unpacked types are not the same when using msgpack::type::variant. #1070
Comments
Thank you for reporting the issue. I think that it is caused by #1018 (#1017). I will take a look |
- msgpack::type::variant behaves as MessagePack format. e.g.) 12.34 => double 12.0 => uint64_t -12.34 => double -12.0 => int64_t - msgpack::type::variant::as_double() can be used even if interval type is int64_t and/or uint64_t. - msgpack::type::variant::as_*() don't return non const reference internal value. - fix coding style
Fixed. Could you try #1071 ? |
Yes, i tried it works. And second, if i want to use user defined variant as in your example here i will face this problem again. |
No, it is NOT a problem. MessagePack format doesn't preserve progiramming language type information. That is by design.
I don't maintain old my gist. User can define type preserve version of custom adaptor if user wants to have it. In order to do that, the user need to pack not only values but also meta data (type information). |
I got it. Thank you for clarification. |
Problem appears when using msgpack::type::variant serialization for float number with zero decimal part.
Here motivation example:
The reason for the failed assert is different types of variant’s values.
There are float type of
val
and uint64 type of therestored_val
I’ve found out that positive float number with zero decimal part is stored as uint64, hence when it is deserialized, it turns into an uint64 number.
As I know, it happens in line 1165 of
msgpack/v1/pack.hpp
, here:Here https://gist.github.com/redboltz/672c5af16b2907488977 same problem.
Thank you for response.
msgpack version: 6.0.0
OS: Windows 10
The text was updated successfully, but these errors were encountered: