-
Notifications
You must be signed in to change notification settings - Fork 908
Open
Description
Describe the bug
I've been using msgpack-c 4.0.0, which does type checking for conversions between float and int.But when I updated to 4.1.3, I found that the same code produced a different behavior.
To Reproduce
Code:
float original_value = 1.0;
msgpack::sbuffer buffer;
msgpack::pack(buffer, original_value);
msgpack::object_handle oh = msgpack::unpack(buffer.data(), buffer.size());
try {
int unpacked_value = oh.get().as<int>();
std::cout << "Unpacked value: " << unpacked_value << std::endl;
} catch (const std::exception& e) {
std::cerr << "Failed to unpack as int " << e.what() << std::endl;
}
Output:
When I run this code with msgpack-c 4.0.0
Failed to unpack as int std::bad_cast
But when I run this code with msgpack-c 4.1.3
Unpacked value: 1
Please prepare https://stackoverflow.com/help/minimal-reproducible-example
Expected behavior
I expect it to report an error, because this kind of unchecked type conversion tends to be problematic.
Metadata
Metadata
Assignees
Labels
No labels