diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index a168e39ef76bd3fc9915370e2f386b2195bb5536..767f4cb58aed85473b0e38b060c78f0bd9807503 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -6681,8 +6681,8 @@ void
 DynamicModel::detrendEquations()
 {
   // We go backwards in the list of trend_vars, to deal correctly with I(2) processes
-  for (nonstationary_symbols_map_t::const_reverse_iterator it = nonstationary_symbols_map.rbegin();
-       it != nonstationary_symbols_map.rend(); ++it)
+  for (auto it = nonstationary_symbols_map.crbegin();
+       it != nonstationary_symbols_map.crend(); ++it)
     for (auto & equation : equations)
       {
         auto *substeq = dynamic_cast<BinaryOpNode *>(equation->detrend(it->first, it->second.first, it->second.second));