diff --git a/src/SubModel.cc b/src/SubModel.cc index 38d3733becca219a34c5101c442d93c5bf6b916f..00cfc7a07b9e3399b0956eb0d627c07c304dd0a5 100644 --- a/src/SubModel.cc +++ b/src/SubModel.cc @@ -1226,15 +1226,18 @@ PacModelTable::transformPass(const lag_equivalence_table_t &unary_ops_nodes, // Associate the coefficients of the linear combination with the right components for (auto [var, coeff] : terms) - if (auto it = find_if(components.begin(), components.end(), - [&](const auto &v) { return get<0>(v) == dynamic_model.AddVariable(var); }); - it != components.end()) - get<4>(*it) = coeff; - else - { - cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var) << ") that is not declared as a 'component'" << endl; - exit(EXIT_FAILURE); - } + { + auto var1 = var; + if (auto it = find_if(components.begin(), components.end(), + [&](const auto &v) { return get<0>(v) == dynamic_model.AddVariable(var1); }); + it != components.end()) + get<4>(*it) = coeff; + else + { + cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var1) << ") that is not declared as a 'component'" << endl; + exit(EXIT_FAILURE); + } + } // Verify that all declared components appear in that equation for (const auto &[component, growth_component, auxname, kind, coeff, growth_neutrality_param, h_indices, original_growth_component, growth_component_info] : components)