From efd3aeb2907f0b144b6bbdac40f9e225bd365e50 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 10 Jul 2020 13:00:15 +0200 Subject: [PATCH] Catch exceptions by const reference to prevent warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e.g. gcc issued: "warning: catching polymorphic type ‘class cl::Error’ by value [-Wcatch-value=]" --- opm/simulators/linalg/bda/openclSolverBackend.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/simulators/linalg/bda/openclSolverBackend.cpp b/opm/simulators/linalg/bda/openclSolverBackend.cpp index 9412e98d6..5bbf4bbe8 100644 --- a/opm/simulators/linalg/bda/openclSolverBackend.cpp +++ b/opm/simulators/linalg/bda/openclSolverBackend.cpp @@ -514,13 +514,13 @@ void openclSolverBackend::initialize(int N_, int nnz_, int dim, doub prec->setKernels(ILU_apply1_k.get(), ILU_apply2_k.get()); - } catch (cl::Error error) { + } catch (const cl::Error& error) { std::ostringstream oss; oss << "OpenCL Error: " << error.what() << "(" << error.err() << ")\n"; oss << getErrorString(error.err()); // rethrow exception OPM_THROW(std::logic_error, oss.str()); - } catch (std::logic_error error) { + } catch (const std::logic_error& error) { // rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs throw error; } @@ -665,13 +665,13 @@ void openclSolverBackend::solve_system(WellContributions& wellContri // actually solve try { gpu_pbicgstab(wellContribs, res); - } catch (cl::Error error) { + } catch (const cl::Error& error) { std::ostringstream oss; oss << "openclSolverBackend::solve_system error: " << error.what() << "(" << error.err() << ")\n"; oss << getErrorString(error.err()); // rethrow exception OPM_THROW(std::logic_error, oss.str()); - } catch (std::logic_error error) { + } catch (const std::logic_error& error) { // rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs throw error; }