Enable and fix most compilation warnings #1104

pull laanwj wants to merge 9 commits into bitcoin:master from laanwj:2012_04_clang changing 23 files +65 −22
  1. laanwj commented at 11:52 AM on April 15, 2012: member

    This pull request enables most compilation warnings (of -Wall -Wextra) and fixes them. I compiled bitcoin-qt with g++ and clang to have as much warning coverage as possible. Warning flags in bitcoin-qt and bitcoind build have been equalized.

    char-subscripts warnings were especially dangerous, as char can be negative, resulting in accesses outside the array and thus potential information leakage. Fixed this by adding (unsigned char).

    I've left these warnings alone:

    • invalid-offsetof: Looked this up, and found http://stackoverflow.com/questions/1129894/why-cant-you-use-offsetof-on-non-pod-strucutures-in-c We use none of the special C++ multi-inheritance and dynamic casting so using offsetof should be safe.
    • sign-compare: There's just too darn many of 'em. These could be worth checking later, as wrong signed-unsigned comparisons can result in nasty bugs.
    • unused-parameter: Also way too many instances. And ignoring a parameter is no problem, usually.

    I have carefully seperated this into commits for each separate warning class to make review easy.

  2. enable all warnings except invalid-offsetof, sign-compare, unused-parameter f9f625fb32
  3. work around issue in boost::program_options that prevents from compiling in clang 1f29d399f4
  4. fix warnings: array subscript is of type 'char' [-Wchar-subscripts] 8add7822ce
  5. fix warnings: 'XX' defined as a struct here but previously declared as a class [-Wmismatched-tags] 87207a2e08
  6. fix warnings: enumeration values 'XX' not handled in switch [-Wswitch-enum] 76d8170ce8
  7. fix warnings: unused variable 'XX' [-Wunused-variable] 11cd416525
  8. fix warnings: delete called on 'XX' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] 2e120f28e0
  9. fix warnings: '&&' within '||' [-Wlogical-op-parentheses] 6642ffb761
  10. fix warnings: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] da7bbd9dfd
  11. sipa commented at 11:58 AM on April 15, 2012: member

    ACK

  12. jgarzik commented at 4:12 PM on April 15, 2012: contributor

    ACK, good work cleaning all that up

  13. jgarzik referenced this in commit 5a701eb7ea on Apr 15, 2012
  14. jgarzik merged this on Apr 15, 2012
  15. jgarzik closed this on Apr 15, 2012

  16. coblee referenced this in commit 92d028eba4 on Jul 17, 2012
  17. laanwj deleted the branch on Apr 9, 2014
  18. suprnurd referenced this in commit d9d6d4f6eb on Dec 5, 2017
  19. lateminer referenced this in commit 2c49c8d608 on Jan 22, 2019
  20. lateminer referenced this in commit 97bea9cfc0 on Nov 14, 2019
  21. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me