gcc 15.2 is really picky about casting between ints of different sizes.

So subvert the warnings with a union.

Note that the exception is deliberatley unhandled: We want to crash out if there are high bits.
pull/2171/head
John Ralls 2 months ago
parent 79b43fb4f6
commit 1d9b80f7ff

@ -367,8 +367,26 @@ GncSqlColumnTableEntry::get_row_value_from_object(QofIdTypeConst obj_name,
{
QofAccessFunc getter = get_getter(obj_name);
if (getter != nullptr)
result = reinterpret_cast<T>((getter)(const_cast<void*>(pObject),
{
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;
}
}
}
return result;
}

Loading…
Cancel
Save