mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
The suspicious code was detected by `gcc-13` as: AI/Nullkiller/Goals/ExecuteHeroChain.cpp: In member function 'virtual void NKAI::Goals::ExecuteHeroChain::accept(NKAI::AIGateway*)': AI/Nullkiller/Goals/ExecuteHeroChain.cpp:130:47: warning: catching polymorphic type 'class NKAI::cannotFulfillGoalException' by value [-Wcatch-value=] 130 | catch(cannotFulfillGoalException) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ AI/Nullkiller/Goals/ExecuteHeroChain.cpp:176:23: warning: catching polymorphic type 'class NKAI::goalFulfilledException' by value [-Wcatch-value=] 176 | catch(goalFulfilledException) | ^~~~~~~~~~~~~~~~~~~~~~ Similar to object passing by value and reference passing polymorphic exceptions by reference likely destroys them when copy-constructed to a base class. Let's catch them by reference.