Skip to content
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

fix get10Byte on platforms where long double is >80 bits. #1195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/utils/byte_value_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,12 @@ bool ByteValueStorage::get10ByteImpl(
{
std::vector<std::uint8_t> d8;
double10ToDouble8(d8, data);
memcpy(&res, d8.data(), d8.size());

double d8res = 0;
static_assert(sizeof(double) == 8);

memcpy(&d8res, d8.data(), d8.size());
res = d8res;
}

return true;
Expand Down
8 changes: 5 additions & 3 deletions src/utils/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "retdec/utils/os.h"
#include "retdec/utils/system.h"

#include <cfloat>

namespace retdec {
namespace utils {

Expand All @@ -22,11 +24,11 @@ bool isLittleEndian() {
}

/**
* @brief Finds out if the runtime system supports <tt>long double</tt> (at least
* 10 bytes long).
* @brief Finds out if the runtime system supports 80-bit <tt>long double</tt>
* (exactly 10 bytes long).
*/
bool systemHasLongDouble() {
return sizeof(long double) >= 10;
return sizeof(long double) >= 10 && (LDBL_MANT_DIG == 64);
}

} // namespace utils
Expand Down