From 1d9b80f7ff4f53c2e8cdaa79d2be3fe5e0625c95 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 5 Jan 2026 17:48:48 -0800 Subject: [PATCH] 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. --- .../sql/gnc-sql-column-table-entry.hpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp index a079751a10..326ba62fb1 100644 --- a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp +++ b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp @@ -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((getter)(const_cast(pObject), + { + if constexpr (sizeof(T) >= sizeof(void*)) + result = reinterpret_cast((getter)(const_cast(pObject), nullptr)); + else + { + union converter + { + intptr_t whole; + uint32_t upper; + uint32_t lower; + }; + converter conv; + conv.whole = reinterpret_cast((getter)(const_cast(pObject), + nullptr)); + if (conv.upper) + throw std::runtime_error("Bits left over when converting pointer"); //crash out + result = conv.lower; + } + } } return result; }