From a13b2b57726da8c4460a04a1c75f52ef7d8866e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 3 Sep 2024 12:05:09 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20k-order=20MEX:=20mutex=20was=20n?=
 =?UTF-8?q?ot=20correctly=20locked=20in=20initialization?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Since the lock was not assigned to a variable, it was a temporary value and
would thus be immediately released.

Problem detected through a warning produced by GCC 14.
---
 mex/sources/libkorder/tl/tl_static.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mex/sources/libkorder/tl/tl_static.cc b/mex/sources/libkorder/tl/tl_static.cc
index 5d7bd04775..b29f55e6cf 100644
--- a/mex/sources/libkorder/tl/tl_static.cc
+++ b/mex/sources/libkorder/tl/tl_static.cc
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 Ondra Kamenik
- * Copyright © 2019-2022 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -55,7 +55,7 @@ init(int dim, int nvar)
     throw TLException(__FILE__, __LINE__,
                       "Problem too large, you should decrease the approximation order");
 
-  std::lock_guard<std::mutex> {mut};
+  std::lock_guard<std::mutex> lk {mut};
   ebundle.generateUpTo(dim);
   pbundle.generateUpTo(dim);
 
-- 
GitLab