A better fix for gcc ptr->int casting pickiness.

pull/2168/head
John Ralls 1 month ago
parent 2f94d1611b
commit b028f50fa3

@ -368,24 +368,8 @@ GncSqlColumnTableEntry::get_row_value_from_object(QofIdTypeConst obj_name,
QofAccessFunc getter = get_getter(obj_name); QofAccessFunc getter = get_getter(obj_name);
if (getter != nullptr) if (getter != nullptr)
{ {
if constexpr (sizeof(T) >= sizeof(void*)) result = static_cast<T>(reinterpret_cast<intptr_t>((getter)(const_cast<void*>(pObject),
result = reinterpret_cast<T>((getter)(const_cast<void*>(pObject), nullptr)));
nullptr));
else
{
union converter
{
intptr_t whole;
uint32_t upper;
uint32_t lower;
};
converter conv;
conv.whole = reinterpret_cast<intptr_t>((getter)(const_cast<void*>(pObject),
nullptr));
if (conv.upper)
throw std::runtime_error("Bits left over when converting pointer"); //crash out
result = conv.lower;
}
} }
} }
return result; return result;

Loading…
Cancel
Save