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

Enable useful compiler warnings, add C++17 attributes to enable optimisation & avoid false warnings #54

Closed
wants to merge 6 commits into from

Conversation

slowriot
Copy link
Contributor

Description

A number of useful compiler warnings have been omitted or disabled in the build script, presumably due to a number of false positives or cases where these warnings do not apply.

This PR enables modifies warnings as follows:

  • Enables warnings for all unused entities, which is very useful for catching subtle and difficult to diagnose bugs
  • Dsables the suppression of the unused parameter warning, which previously silenced a large number of the above warnings
  • Adds warnings to suggest const and noreturn attributes, which allow further compiler optimisations if functions that can be marked as such are found by the compiler.
  • Adds commented options to generate warnings for suggested pure and final attributes, to allow developers to easily enable them temporarily for diagnostics, without generating unnecessary noise due to false positives.

This PR then proceeds to resolve hundreds of instances of those warnings throughout the code, primarily by applying relevant C++17 attributes as follows:

  • Parameters that are intentionally unused (for example, in overridden functions or empty polymorphic base functions) are marked with [[maybe_unused]]. Any new code that unintentionally fails to use a parameter will be flagged by the -Wunused warning. The presence of this attribute also makes the design intention clear to readers, and avoids reliance on comments or variable names such as "ignored" as presently found in the code.
  • Inherited classes that are not derived from elsewhere are marked final, which enables devirtualisation of certain calls, and improves optimised performance.
  • Virtual functions that are not overridden elsewhere are marked final, which enables the compiler to devirtualise function calls, improving optimised performance likewise.

BTC/BGL PR reward address

ETH/USDT: 0x50b92AB67A3D3DE8c3506D9287893D9a52655486

@janus
Copy link
Collaborator

janus commented Sep 7, 2021

This PR is great but we won't accept it. We want to be as close as possible to Bitcoin codebase.

@janus
Copy link
Collaborator

janus commented Sep 7, 2021

We won't accept this PR. It does not bring much value.

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.

3 participants