From 67bce9e9c2273f4e99cc034b9812128790568277 Mon Sep 17 00:00:00 2001 From: Neal Siekierski Date: Tue, 17 May 2022 09:28:34 -0400 Subject: [PATCH] Fix undefined or incorrect behavior in darknet_trainer Per rule 20 of the "Sequenced-before rules" at https://en.cppreference.com/w/cpp/language/eval_order, starting in C++17 the right-hand side of an assignment is evaluated before the left-hand side, which is not the desired behavior. Prior to C++17, the behavior is, as I understand it, undefined. --- arrows/darknet/darknet_trainer.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arrows/darknet/darknet_trainer.cxx b/arrows/darknet/darknet_trainer.cxx index d254836472..84222c4e30 100644 --- a/arrows/darknet/darknet_trainer.cxx +++ b/arrows/darknet/darknet_trainer.cxx @@ -845,7 +845,8 @@ ::print_detections( { if( m_category_map.find( category ) == m_category_map.end() ) { - m_category_map[ category ] = m_category_map.size() - 1; + int id = m_category_map.size(); + m_category_map[ category ] = id; } category = std::to_string( m_category_map[ category ] ); }