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

[Compilation] Pass caught exceptions by reference #979

Open
wants to merge 3 commits into
base: master
from

Conversation

@Warrows
Copy link
Collaborator

commented Aug 6, 2019

Gets rid of compiler warnings such as "warning: catching polymorphic type 'class std::runtime_error' by value [-Wcatch-value=]"

@Warrows Warrows self-assigned this Aug 6, 2019

@CaveSpectre11

This comment has been minimized.

Copy link

commented Aug 6, 2019

Some questions:

  • The format is consistent in these changes, but it's not consistent through the code base. Should the format be <datatype>& <identifier> or <datatype> &<identifier>?
  • without an identifier; some places in the code are by reference, some by value
    test\alert_tests\cpp Line 96: catch (std::exception) { }
    rpc\rawtransaction.cpp Line 620: } catch (const std::exception&) {
  • While we're at it; should we define the catches to be const?
  • Should this be expanded to include the test modules?
    test\benchmark_zerocoin.cpp
    test\libzerocoin_tests.cpp
    test\alert_tests.cpp

@Warrows Warrows force-pushed the Warrows:2019-08_exceptions-by-ref branch 2 times, most recently from 1954e3d to 3b61e81 Aug 7, 2019

@Warrows

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 7, 2019

Addressing your questions:

  • Well that's my bad because https://github.com/PIVX-Project/PIVX/blob/master/doc/developer-notes.md#coding-style-c specifies that the desired format is <datatype>& <identifier>. I fixed it.
  • I fixed the warnings thrown by my compiler. Here is an explanation about the reasons behind this warning: https://blog.knatten.org/2010/04/02/always-catch-exceptions-by-reference/ We can assume that the places such as test\alert_tests\cpp Line 96: catch (std::exception) { } don't throw a warning because the exception is not used, thus we don't really care if it's missing some specific methods or data. I fixed it anyway so it can be used safely in the future.
  • Indeed, adding const to exceptions catching is not that important of a change but it's always good to have. So I added it too.
  • Of course test modules must be included. And they were. Only alert_tests.cpp wasn't changed because as I said above it didn't throw a warning. That's done too now.
@CaveSpectre11

This comment has been minimized.

Copy link

commented Aug 7, 2019

Good reference; I will check it out so I can be more authoritative in the future ;)

@Warrows Warrows force-pushed the Warrows:2019-08_exceptions-by-ref branch from cbf73a6 to 05e8d12 Aug 7, 2019

Warrows added some commits Aug 6, 2019

[Compilation] Pass caught exceptions by reference
Gets rid of compiler warnings such as "warning: catching polymorphic type 'class std::runtime_error' by value [-Wcatch-value=]"

@Warrows Warrows force-pushed the Warrows:2019-08_exceptions-by-ref branch from 05e8d12 to 5780e0d Aug 14, 2019

@Warrows Warrows added this to the 4.0.0 milestone Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.