Boost Users :
Subject: [Boost-users] boost::endian::native_to_big_inplace fails with char
From: Martijn Otto (boost_at_[hidden])
Date: 2019-03-18 15:47:55
I am having issues with boost::endian:native_to_big_inplace when used
with a char. Whatever you try to 'reverse' comes out as 0.
Looking through the code, on little endian machines it calls
endian_reverse (as expected). This function has no overload for a char
and it then gets promoted to an int.
Since the int _is_ actually larger than 1 byte, something gets
reversed. The native_to_big_inplace then returns it as a char,
narrowing the int and throwing away all the relevant bits, resulting in
I found an issue on github about this: https://github.com/boostorg/endi
an/issues/10 about exactly this issue. The bug is easily shown if you
try to compile
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net