From 2e30e6df59c994b9aef7b751e57e8429d05365ae Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 28 Apr 2025 19:11:38 +0200 Subject: [PATCH] whisper : fix grammar advance stack warning (#3087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit addresses a warnings that is present for Release builds: ```console [ 30%] Building CXX object src/CMakeFiles/whisper.dir/whisper.cpp.o In file included from /usr/include/c++/13/bits/stl_tree.h:63, from /usr/include/c++/13/map:62, from /home/danbev/work/ai/whisper.cpp/src/whisper-arch.h:5, from /home/danbev/work/ai/whisper.cpp/src/whisper.cpp:2: In static member function ‘static void std::__copy_move::__assign_one(_Tp*, _Up*) [with _Tp = const whisper_grammar_element*; _Up = const whisper_grammar_element* const]’, inlined from ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const whisper_grammar_element* const; _Up = const whisper_grammar_element*; bool _IsMove = false]’ at /usr/include/c++/13/bits/stl_algobase.h:440:20, inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const whisper_grammar_element* const*; _OI = const whisper_grammar_element**]’ 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 = const whisper_grammar_element* const*; _OI = const whisper_grammar_element**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42, ... ``` This warning is caused by the fact that the `stack` vector is empty when it is passed to `new_stacks.push_back(stack);`. The suggested fix is to use `new_stacks.emplace_back();` instead of `new_stacks.push_back(stack);`. --- src/whisper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/whisper.cpp b/src/whisper.cpp index 2c83f7ba..53b07592 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -4501,7 +4501,7 @@ static void whisper_grammar_advance_stack( std::vector> & new_stacks) { if (stack.empty()) { - new_stacks.push_back(stack); + new_stacks.emplace_back(); return; }