diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp index d37bdba1..c6a34906 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -327,8 +327,9 @@ namespace Catch { void handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); + std::vector const& constUnfinishedSections = m_unfinishedSections; + for( std::vector::const_reverse_iterator it = constUnfinishedSections.rbegin(), + itEnd = constUnfinishedSections.rend(); it != itEnd; ++it ) sectionEnded( *it );