From aff33623c003b34b19e592c905cd7b3e86d204db Mon Sep 17 00:00:00 2001 From: Ole Erik Peistorpet Date: Mon, 27 May 2024 22:35:16 +0200 Subject: [PATCH] Attempt at fix for GCC warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘void* memcpy(void*, const void*, size_t)’, inlined from ‘T* oel::dynarray::emplace(const_iterator, Args&& ...) & [with Args = {dynarrayTest_overAligned_Test::TestBody()::Type}; T = dynarrayTest_overAligned_Test::TestBody()::Type; Alloc = oel::allocator<>]’ at dynarray.h:614:13, inlined from ‘T* oel::dynarray::insert(const_iterator, T&&) & [with T = dynarrayTest_overAligned_Test::TestBody()::Type; Alloc = oel::allocator<>]’ at OE-Lib/dynarray.h:164:72, inlined from ‘virtual void dynarrayTest_overAligned_Test::TestBody()’ at OE-Lib/unit_test/dynarray_mutate_gtest.cpp:893:16: warning: ‘tmp’ may be used uninitialized [-Wmaybe-uninitialized] --- dynarray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynarray.h b/dynarray.h index 192206ba..62d65f65 100644 --- a/dynarray.h +++ b/dynarray.h @@ -593,7 +593,7 @@ typename dynarray::iterator OEL_DYNARR_INSERT_STEP1 // Temporary in case constructor throws or args refer to an element of this dynarray - storage_for tmp; + alignas(T) unsigned char tmp[sizeof(T)]; _alloTrait::construct(_m, reinterpret_cast(&tmp), static_cast(args)...); if (_m.end < _m.reservEnd) { // Relocate [pos, end) to [pos + 1, end + 1)