From 5eb769008b32157d31929157ee95c8f955452ecf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 31 Aug 2021 12:34:44 +0200
Subject: [PATCH] Dynare++: fix bug in the --steps option

This option could crash or give wrong results.

Bug introduced in 6d99b6d1208580c2b91e8f00a51da7d139c93e2e.
The Vector(Vector &) and Vector(const Vector &) constructors are not
equivalent.

Closes: #1804
---
 dynare++/kord/approximation.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dynare++/kord/approximation.cc b/dynare++/kord/approximation.cc
index c10be1696..6934ec6d2 100644
--- a/dynare++/kord/approximation.cc
+++ b/dynare++/kord/approximation.cc
@@ -154,7 +154,7 @@ Approximation::walkStochSteady()
       JournalRecordPair pa(journal);
       pa << "Approximation about stochastic steady for sigma=" << sigma_so_far+dsigma << endrec;
 
-      Vector last_steady(model.getSteady());
+      Vector last_steady(const_cast<const Vector &>(model.getSteady()));
 
       // calculate fix-point of the last rule for ‘dsigma’
       /* We form the DRFixPoint object from the last rule with σ=dsigma. Then
@@ -180,7 +180,7 @@ Approximation::walkStochSteady()
          minus the old steady state. Then we create StochForwardDerivs object,
          which calculates the derivatives of g** expectations at new sigma and
          new steady. */
-      Vector dy(model.getSteady());
+      Vector dy(const_cast<const Vector &>(model.getSteady()));
       dy.add(-1.0, last_steady);
 
       StochForwardDerivs<Storage::fold> hh(ypart, model.nexog(), *rule_ders_ss, mom, dy,
-- 
GitLab