Skip to content

Commit

Permalink
Cleanup: Fix compilation warning
Browse files Browse the repository at this point in the history
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<vkb::rendering::Light*, vector<vkb::rendering::Light> >; _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<vkb::rendering::Light*, vector<vkb::rendering::Light> >; _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<vkb::sg::Light*>&, 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;
      |                           ^~~~~~~~~~

```
  • Loading branch information
jeroenbakker-atmind committed Dec 11, 2024
1 parent 3751770 commit c1032d6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit c1032d6

Please sign in to comment.