sqlite_modern_cpp icon indicating copy to clipboard operation
sqlite_modern_cpp copied to clipboard

Catch exception objects by const reference

Open Peter-Levine opened this issue 7 years ago • 1 comments

Testing with latest GCC git master (8.0.1) results in errors such as:

tests/flags.cc: In function ‘int main()’:
tests/flags.cc:99:25: error: catching polymorphic type ‘class sqlite::sqlite_exception’ by value [-Werror=catch-value=]
  catch(sqlite_exception e)
                         ^

sqlite_exception should ideally be caught by reference (and, preferably, const reference) to avoid potential issues such as object slicing and memory exhaustion triggering further exceptions.

Peter-Levine avatar Apr 03 '18 00:04 Peter-Levine

@Peter-Levine Thanks for the PR.

I think if i merge this, then we will get conflicts with dev branch. In our dev branch we have moved the tests to use Catch2. Also the tests in dev are not (should not be) using try {} catch blocks.

Could you please have a look at dev branch, we definitely need to fix it.

aminroosta avatar Apr 03 '18 08:04 aminroosta