From 0d981419ee65383400c20655a5f04ce4c9d7c741 Mon Sep 17 00:00:00 2001
From: Jesper Andersson <jesper.andersson@ndcn.ox.ac.uk>
Date: Thu, 9 Dec 2021 15:21:09 +0000
Subject: [PATCH] changes to exceptions that returned pointer to temporary
 object

---
 SpMat.h    | 4 ++--
 bfmatrix.h | 4 ++--
 nonlin.h   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/SpMat.h b/SpMat.h
index ae81cc6..8734f62 100644
--- a/SpMat.h
+++ b/SpMat.h
@@ -39,10 +39,10 @@ class SpMatException: public std::exception
 private:
   std::string m_msg;
 public:
-  SpMatException(const std::string& msg) throw(): m_msg(msg) {}
+  SpMatException(const std::string& msg) throw(): m_msg(std::string("SpMat::")+msg) {}
 
   virtual const char * what() const throw() {
-    return std::string("SpMat::" + m_msg).c_str();
+    return(m_msg.c_str());
   }
 
   ~SpMatException() throw() {}
diff --git a/bfmatrix.h b/bfmatrix.h
index 92ef6e3..1db8810 100644
--- a/bfmatrix.h
+++ b/bfmatrix.h
@@ -42,10 +42,10 @@ class BFMatrixException: public std::exception
 private:
   std::string m_msg;
 public:
-  BFMatrixException(const std::string& msg) throw(): m_msg(msg) {}
+  BFMatrixException(const std::string& msg) throw(): m_msg(std::string("BFMatrix::")+msg) {}
 
   virtual const char * what() const throw() {
-    return std::string("BFMatrix::" + m_msg).c_str();
+    return(m_msg.c_str());
   }
 
   ~BFMatrixException() throw() {}
diff --git a/nonlin.h b/nonlin.h
index a0d0fdf..4e8b17a 100644
--- a/nonlin.h
+++ b/nonlin.h
@@ -65,10 +65,10 @@ class NonlinException: public std::exception
 private:
   std::string m_msg;
 public:
-  NonlinException(const std::string& msg) throw(): m_msg(msg) {}
+  NonlinException(const std::string& msg) throw(): m_msg(std::string("Nonlin: msg=")+msg) {}
 
   virtual const char * what() const throw() {
-    return std::string("Nonlin: msg=" + m_msg).c_str();
+    return(m_msg.c_str());
   }
 
   ~NonlinException() throw() {}
-- 
GitLab