From 3ce764a90b1aa9a8c8b5ecda9ae29cd9af663941 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Fri, 12 Jul 2019 13:29:02 -0600 Subject: [PATCH] Fixes for cppcheck 1.88 --- src/tools/Stopwatch.h | 10 +++++++++- src/tools/Tensor.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools/Stopwatch.h b/src/tools/Stopwatch.h index 0cf4e9a9c..921de177c 100644 --- a/src/tools/Stopwatch.h +++ b/src/tools/Stopwatch.h @@ -338,7 +338,15 @@ inline Stopwatch::Handler & Stopwatch::Handler::operator=(Handler && handler) noexcept { if(this!=&handler) { if(watch) { - if(stop) watch->stop(); + if(stop) { + try { + watch->stop(); + } catch(...) { +// this is to avoid problems with cppcheck, given than this method is declared as +// noexcept and stop might throw in case of an internal bug + std::terminate(); + } + } else watch->pause(); } // cppcheck complains about this: diff --git a/src/tools/Tensor.h b/src/tools/Tensor.h index b8c5c23be..a62009beb 100644 --- a/src/tools/Tensor.h +++ b/src/tools/Tensor.h @@ -545,7 +545,7 @@ void diagMatSym(const TensorGeneric<n,n>&mat,VectorGeneric<m>&evals,TensorGeneri int lwork=work.size(); TensorGenericAux::local_dsyevr("V", (n==m?"A":"I"), "U", &nn, const_cast<double*>(&mat[0][0]), &nn, &vl, &vu, &one, &mm, &abstol, &mout, &evals[0], &evec[0][0], &nn, - &isup[0], &work[0], &lwork, &iwork[0], &liwork, &info); + isup.data(), work.data(), &lwork, iwork.data(), &liwork, &info); if(info!=0) plumed_error()<<"Error diagonalizing matrix\n" <<"Matrix:\n"<<mat<<"\n" <<"Info: "<<info<<"\n"; -- GitLab