From 634a3d69ec043a19528087fde3423ce7c519ea3d Mon Sep 17 00:00:00 2001
From: MichelJuillard <michel.juillard@mjui.fr>
Date: Wed, 5 Jan 2022 15:54:40 +0100
Subject: [PATCH] minor changes to allow compiling with clang

---
 src/EquationTags.hh |  5 +++--
 src/SubModel.cc     | 21 ++++++++++++---------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/EquationTags.hh b/src/EquationTags.hh
index 34277bae..7db769b3 100644
--- a/src/EquationTags.hh
+++ b/src/EquationTags.hh
@@ -20,12 +20,13 @@
 #ifndef _EQUATION_TAGS_HH
 #define _EQUATION_TAGS_HH
 
-using namespace std;
-
+#include <iostream>
 #include <map>
 #include <set>
 #include <string>
 
+using namespace std;
+
 class EquationTags
 {
 private:
diff --git a/src/SubModel.cc b/src/SubModel.cc
index 8d59e5dd..f2e0699e 100644
--- a/src/SubModel.cc
+++ b/src/SubModel.cc
@@ -1006,15 +1006,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 tmp = dynamic_model.AddVariable(var);
+	      if (auto it = find_if(components.begin(), components.end(),
+				    [& tmp = tmp](const auto &v) { return get<0>(v) == tmp; });
+		  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);
+		}
+	    }
 
           // 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)
-- 
GitLab