It is generally a bad idea to catch exceptions by value, because it
forces an unnecessary copy of the caught value. It's even worse when
the type is polymorphic - in that case the copy will only be a slice
of the original type. This is why recent compilers started to warn
when code catches a polymorphic type by value.

In the specific case fixed here, the warning is spurious, because the
caught exception isn't even used. But it's trivial to fix it, and get
rid of one more warning during test compilation.

Refs #976

Signed-off-by: Nadav Har'El <[email protected]>
---
 tests/tst-run.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tst-run.cc b/tests/tst-run.cc
index 3f1139c3..2a9a8f51 100644
--- a/tests/tst-run.cc
+++ b/tests/tst-run.cc
@@ -44,7 +44,7 @@ int main(int ac, char** av)
         osv::run("/nonexistant.so", 0, nullptr, nullptr);
         // should throw and not get here
         report(false, "Run nonexistant");
-    } catch(osv::launch_error) {
+    } catch(osv::launch_error&) {
         report(true, "Run nonexistant");
     }
 
-- 
2.21.0

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20191128084425.16490-1-nyh%40scylladb.com.

Reply via email to