Fix deep const-cast in ivector pointer repair for const pointee types (#1511)

to_void_pptr() previously stripped const from the pointed-to type via
element_type, breaking pointer-to-const element types such as
etl::vector<const int*>. Convert through void* instead, removing only the
buffer's top-level const and avoiding reinterpret_cast.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
Roland Reichwein 2026-07-20 13:53:21 +02:00 committed by GitHub
parent a74c33bab9
commit 83831216d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1212,8 +1212,6 @@ namespace etl
typedef pvoidvector base_t;
typedef typename etl::remove_const<typename etl::remove_pointer<T>::type>::type* element_type;
template <typename TIterator>
struct is_compatible_iterator
: etl::bool_constant<etl::is_pointer<typename etl::iterator_traits<TIterator>::value_type>::value
@ -1728,7 +1726,10 @@ namespace etl
// Convert from pointer to void**
static ETL_CONSTEXPR14 void** to_void_pptr(pointer p_buffer) ETL_NOEXCEPT
{
return reinterpret_cast<void**>(const_cast<element_type*>(p_buffer));
ETL_STATIC_ASSERT(!etl::is_const<typename etl::remove_pointer<pointer>::type>::value,
"to_void_pptr must not remove const from the pointed-to element type");
return static_cast<void**>(const_cast<void*>(static_cast<const void*>(p_buffer)));
}
};