[ox] Fix for a broken new memory safety check in GCC13
This commit is contained in:
parent
f63fe6c995
commit
fcf0a9be95
18
deps/ox/src/ox/std/vector.hpp
vendored
18
deps/ox/src/ox/std/vector.hpp
vendored
@ -26,6 +26,8 @@ namespace detail {
|
|||||||
|
|
||||||
template<typename T, typename Allocator, std::size_t Size = 1>
|
template<typename T, typename Allocator, std::size_t Size = 1>
|
||||||
struct VectorAllocator {
|
struct VectorAllocator {
|
||||||
|
static_assert(sizeof(AllocAlias<T>) == sizeof(T));
|
||||||
|
static_assert(alignof(AllocAlias<T>) == alignof(T));
|
||||||
private:
|
private:
|
||||||
ox::Array<AllocAlias<T>, Size> m_data = {};
|
ox::Array<AllocAlias<T>, Size> m_data = {};
|
||||||
Allocator m_allocator;
|
Allocator m_allocator;
|
||||||
@ -46,11 +48,11 @@ struct VectorAllocator {
|
|||||||
constexpr void moveConstructItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
|
constexpr void moveConstructItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
if (cap <= Size && count <= Size) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
const auto dstItems = reinterpret_cast<T*>(m_data.data());
|
|
||||||
const auto srcItems = reinterpret_cast<T*>(src->m_data.data());
|
|
||||||
for (auto i = 0u; i < count; ++i) {
|
for (auto i = 0u; i < count; ++i) {
|
||||||
std::construct_at<T>(&dstItems[i], std::move(srcItems[i]));
|
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
||||||
|
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
||||||
|
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
@ -59,11 +61,11 @@ struct VectorAllocator {
|
|||||||
constexpr void moveItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
|
constexpr void moveItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
if (cap <= Size && count <= Size) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
const auto dstItems = reinterpret_cast<T*>(m_data.data());
|
|
||||||
const auto srcItems = reinterpret_cast<T*>(src->m_data.data());
|
|
||||||
for (std::size_t i = 0; i < count; ++i) {
|
for (std::size_t i = 0; i < count; ++i) {
|
||||||
dstItems[i] = std::move(srcItems[i]);
|
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
||||||
|
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
||||||
|
*dstItem = std::move(*srcItem);
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user