Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exception objects by const reference #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Peter-Levine
Copy link

@Peter-Levine Peter-Levine commented Apr 3, 2018

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.

@aminroosta
Copy link
Collaborator

@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.

zauguin added a commit to zauguin/sqlite_modern_cpp that referenced this pull request Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants