From c1032d694629ff6b15fd248adcce48192a09a7e1 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 11 Dec 2024 10:25:28 +0100 Subject: [PATCH] Cleanup: Fix compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On linux/gcc specialization constants sample has a compilation warning ``` n static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = vkb::rendering::Light; _Up = vkb::rendering::Light; bool _IsMove = false]’, inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = vkb::rendering::Light*; _OI = vkb::rendering::Light*]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30, inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = vkb::rendering::Light*; _OI = vkb::rendering::Light*]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42, inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator >; _OI = vkb::rendering::Light*]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31, inlined from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator >; _OI = vkb::rendering::Light*]’ at /usr/include/c++/13/bits/stl_algobase.h:633:7, inlined from ‘vkb::BufferAllocationC SpecializationConstants::ForwardSubpassCustomLights::allocate_custom_lights(vkb::CommandBuffer&, const std::vector&, size_t) [with T = CustomForwardLights]’ at /home/jeroen/vulkan-git/vulkan-samples/samples/performance/specialization_constants/specialization_constants.h:96:13, inlined from ‘virtual void SpecializationConstants::ForwardSubpassCustomLights::draw(vkb::CommandBuffer&)’ at /home/jeroen/vulkan-git/vulkan-samples/samples/performance/specialization_constants/specialization_constants.cpp:142:66: /usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ writing between 65 and 9223372036854775807 bytes into a region of size 64 overflows the destination [-Wstringop-overflow=] 437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jeroen/vulkan-git/vulkan-samples/samples/performance/specialization_constants/specialization_constants.h: In member function ‘virtual void SpecializationConstants::ForwardSubpassCustomLights::draw(vkb::CommandBuffer&)’: /home/jeroen/vulkan-git/vulkan-samples/samples/performance/specialization_constants/specialization_constants.h:76:27: note: at offset 16 into destination object ‘light_info’ of size 80 76 | T light_info; | ^~~~~~~~~~ ``` --- .../specialization_constants/specialization_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/performance/specialization_constants/specialization_constants.h b/samples/performance/specialization_constants/specialization_constants.h index 8c7e11d52..7f934e779 100644 --- a/samples/performance/specialization_constants/specialization_constants.h +++ b/samples/performance/specialization_constants/specialization_constants.h @@ -93,7 +93,7 @@ class SpecializationConstants : public vkb::VulkanSampleC } } - std::copy(lights.begin(), lights.end(), light_info.lights); + std::copy_n(lights.begin(), light_count, light_info.lights); auto &render_frame = get_render_context().get_active_frame(); vkb::BufferAllocationC light_buffer = render_frame.allocate_buffer(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, sizeof(T));