From e7b619c0ef3316daba340ac4ade0d4b297e72603 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 11 Jul 2019 18:35:42 +0200
Subject: [PATCH] Fix handling of underflows and overflows in
 load_params_and_steady_state

Basically revert the change made in 30c205f418459bd6d2003378f06bea7d38cfc562,
since it lead to preprocessor crashes (via C++ exceptions).
---
 src/NumericalInitialization.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/NumericalInitialization.cc b/src/NumericalInitialization.cc
index 8e899668..e004adc4 100644
--- a/src/NumericalInitialization.cc
+++ b/src/NumericalInitialization.cc
@@ -619,5 +619,8 @@ void
 LoadParamsAndSteadyStateStatement::fillEvalContext(eval_context_t &eval_context) const
 {
   for (const auto & it : content)
-    eval_context[it.first] = stod(it.second);
+    /* We use strtod() instead of stod() because we want overflows and
+       underflows to respectively yield 0 and ±Inf. See also the comment in
+       NumericalConstants.cc */
+    eval_context[it.first] = strtod(it.second.c_str(), nullptr);
 }
-- 
GitLab