diff --git a/src/corelib/global/q17memory.h b/src/corelib/global/q17memory.h index aef26b8f382..ae1c55272fd 100644 --- a/src/corelib/global/q17memory.h +++ b/src/corelib/global/q17memory.h @@ -16,6 +16,13 @@ namespace q17 { #if !defined(Q_OS_VXWORKS) using std::uninitialized_value_construct; #else + namespace _detail { + template + void *voidify(T &t) { + // LWG3870 changed this for C++23, but this is q_17_, so use the C++17/20 version: + return const_cast(static_cast(std::addressof(t))); + } + } // namespace _detail // WindRiver confirmed that implementation of `std::uninitialized_value_construct` is not // working properly in VxWorks 24.03 (probably the same problem appears in older versions) with // defect VXHVP-9969 @@ -26,7 +33,7 @@ namespace q17 { using ValueType = typename std::iterator_traits::value_type; QT_TRY { for (; current != last; ++current) - ::new (static_cast(std::addressof(*current))) ValueType(); + ::new (_detail::voidify(*current)) ValueType(); } QT_CATCH(...) { std::destroy(first, current); QT_RETHROW;