Public bug reported:
There is a bug in the upstream 6.1.0 / 6.1.1 version, the coding of
float does, in msgpack/v1/pack.hpp
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_float(float d)
{
if(d == d) { // check for nan
// compare d to limits to avoid undefined behaviour
if(d >= 0 && d <= float(std::numeric_limits<uint64_t>::max()) && d ==
float(uint64_t(d))) {
pack_imp_uint64(uint64_t(d));
return *this;
} else if(d < 0 && d >= float(std::numeric_limits<int64_t>::min()) && d
== float(int64_t(d))) {
pack_imp_int64(int64_t(d));
return *this;
}
}
union { float f; uint32_t i; } mem;
mem.f = d;
char buf[5];
buf[0] = static_cast<char>(0xcau); _msgpack_store32(&buf[1], mem.i);
append_buffer(buf, 5);
return *this;
}
Simular for double. For float this is silly, some floats are packed in 9
byte long (u)int, instead of standard 5 for float. For double it is also
silly, because of the additional conversion for any long int being
packed in 9 bytes, saving no space, but using cpu.
Upstream 7.0.0 reverted to standard float/double packing, not packing as
int, and does not have this problem.
** Affects: msgpack-cxx (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2096913
Title:
Incorrect coding of float and double
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/msgpack-cxx/+bug/2096913/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs