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

This commit is contained in:
John Ralls committed 2026-01-13 11:06:54 -08:00
1 parent 2f94d1611b
commit b028f50fa3
1 file changed
+2 -18
@@ -368,24 +368,8 @@ GncSqlColumnTableEntry::get_row_value_from_object(QofIdTypeConst obj_name,
QofAccessFunc getter = get_getter(obj_name);
if (getter != nullptr)
{
if constexpr (sizeof(T) >= sizeof(void*))
result = reinterpret_cast<T>((getter)(const_cast<void*>(pObject),
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;
}
result = static_cast<T>(reinterpret_cast<intptr_t>((getter)(const_cast<void*>(pObject),
nullptr)));
}
}
return result;