From 96f5161f8e5797c6f8faea644aa02e4561004e91 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Thu, 6 Sep 2018 11:05:33 +0200 Subject: [PATCH] Catch polymorphic exceptions by reference Capturing any polymorphic object by value is wrong, and gcc 8 started to warn about this in the case of exceptions. --- src/compute-disc-error.cc | 2 +- src/cosserat-continuum.cc | 2 +- src/gradient-flow.cc | 2 +- src/mixed-cosserat-continuum.cc | 2 +- test/adolctest.cc | 2 +- test/frameinvariancetest.cc | 2 +- test/localgfetestfunctiontest.cc | 2 +- test/rodassemblertest.cc | 2 +- test/rotationtest.cc | 2 +- test/targetspacetest.cc | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compute-disc-error.cc b/src/compute-disc-error.cc index 68a76036..b0cf6c03 100644 --- a/src/compute-disc-error.cc +++ b/src/compute-disc-error.cc @@ -644,7 +644,7 @@ int main (int argc, char *argv[]) try return 0; } -catch (Exception e) +catch (Exception& e) { std::cout << e << std::endl; return 1; diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index c9c6bf34..2bd4f609 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -454,7 +454,7 @@ int main (int argc, char *argv[]) try } // ////////////////////////////// - } catch (Exception e) { + } catch (Exception& e) { std::cout << e << std::endl; diff --git a/src/gradient-flow.cc b/src/gradient-flow.cc index 39716267..60f837f4 100644 --- a/src/gradient-flow.cc +++ b/src/gradient-flow.cc @@ -300,7 +300,7 @@ int main (int argc, char *argv[]) try return 0; } -catch (Exception e) +catch (Exception& e) { std::cout << e.what() << std::endl; return 1; diff --git a/src/mixed-cosserat-continuum.cc b/src/mixed-cosserat-continuum.cc index aecd926c..05098215 100644 --- a/src/mixed-cosserat-continuum.cc +++ b/src/mixed-cosserat-continuum.cc @@ -404,7 +404,7 @@ int main (int argc, char *argv[]) try << ", average deflection: " << averageDef << std::endl; } - } catch (Exception e) { + } catch (Exception& e) { std::cout << e << std::endl; diff --git a/test/adolctest.cc b/test/adolctest.cc index a97174af..523d7406 100644 --- a/test/adolctest.cc +++ b/test/adolctest.cc @@ -588,7 +588,7 @@ int main (int argc, char *argv[]) try } // ////////////////////////////// - } catch (Exception e) { + } catch (Exception& e) { std::cout << e << std::endl; diff --git a/test/frameinvariancetest.cc b/test/frameinvariancetest.cc index f9a355a8..24b4151c 100644 --- a/test/frameinvariancetest.cc +++ b/test/frameinvariancetest.cc @@ -97,7 +97,7 @@ int main (int argc, char *argv[]) try } - } catch (Exception e) { + } catch (Exception& e) { std::cout << e.what() << std::endl; diff --git a/test/localgfetestfunctiontest.cc b/test/localgfetestfunctiontest.cc index dee684c7..34ff67bd 100644 --- a/test/localgfetestfunctiontest.cc +++ b/test/localgfetestfunctiontest.cc @@ -83,7 +83,7 @@ int main() try test<Rotation<double,3>, 1>(); test<Rotation<double,3>, 2>(); -} catch (Exception e) { +} catch (Exception& e) { std::cout << e << std::endl; } diff --git a/test/rodassemblertest.cc b/test/rodassemblertest.cc index 6542a074..aa737baf 100644 --- a/test/rodassemblertest.cc +++ b/test/rodassemblertest.cc @@ -571,7 +571,7 @@ int main (int argc, char *argv[]) try hessianFDCheck(x, hessianMatrix, rodAssembler); // ////////////////////////////// - } catch (Exception e) { + } catch (Exception& e) { std::cout << e << std::endl; diff --git a/test/rotationtest.cc b/test/rotationtest.cc index bf349d2f..ac4f2f6a 100644 --- a/test/rotationtest.cc +++ b/test/rotationtest.cc @@ -395,7 +395,7 @@ int main (int argc, char *argv[]) try return not passed; - } catch (Exception e) { + } catch (Exception& e) { std::cout << e << std::endl; diff --git a/test/targetspacetest.cc b/test/targetspacetest.cc index 820f3e81..cadfe481 100644 --- a/test/targetspacetest.cc +++ b/test/targetspacetest.cc @@ -384,7 +384,7 @@ int main() try // // test<HyperbolicHalfspacePoint<double,2> >(); -} catch (Exception e) { +} catch (Exception& e) { std::cout << e << std::endl; -- GitLab