Skip to content

Commit

Permalink
tests: fix compilation warning in tests/tst-run.cc
Browse files Browse the repository at this point in the history
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]>
Message-Id: <[email protected]>
  • Loading branch information
nyh authored and wkozaczuk committed Nov 28, 2019
1 parent 0edc01a commit 9e40fc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/tst-run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 9e40fc8

Please sign in to comment.