Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Mar 17, 2021

With C++17 [[maybe_unused]] attribute it is easy to keep emerged cases in the new code under control.

This PR does not touch -Wno-unused-parameter as it requires too much of code churning.


Compiler specific notes:

  1. clang:
  • -Wunused-macros not added because it requires a non-trivial checking in the configure script, and it blames only
    #define _POSIX_C_SOURCE 200112L
  • -Wunused-template not added because some of our templates are buried into macros
  • -Wused-but-marked-unused produces tones of warnings in boost tests
  1. gcc
  • -Werror=unused-const-variable with level 2 seems not suitable for C++ code

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 17, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23191 (build: Disable -Wbraced-scalar-init, which is incompatible with -Wc++11-narrowing by MarcoFalke)
  • #23149 (build: make --enable-werror just -Werror by fanquake)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@practicalswift
Copy link
Contributor

Concept ACK, but why the removal of -Werror=unused-variable? :)

Could you describe some tests cases that could be used to verify that the patch in this PR makes the build fail where we expect it to fail?

-Wunused-local-typedef(s) is covered by -Wunused in both gcc and clang.
No new warnings fire when compiling.
Added flags are disabled by default.
No new warnings fire when compiling.
Added flag is disabled by default for C++.
No new warnings fire when compiling.
@hebasto
Copy link
Member Author

hebasto commented Aug 24, 2021

Rebased 22dd4fb -> 424683d (pr21458.01 -> pr21458.02).

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~0. I'm not super convinced about the addition of (post rebase, and without -Wunused) two, specific -Wunused-* flags. See also #23269 where I've cherry-picked 33a3554.

@@ -445,8 +448,10 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wunused-member-function],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-member-function"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wunused], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused"], [], [$CXXFLAG_WERROR])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 86bb9d8: -Wunused is already part of -Wall (via -Wmost) for Clang, and is implied by -Wall for GCC, so this should be redundant.

fanquake added a commit that referenced this pull request Oct 14, 2021
aa69fd6 build: Drop -Wno-unused-local-typedef (Hennadii Stepanov)
672e8c5 build: remove -Wunused-variable (fanquake)
5239af0 build: remove -Wswitch (fanquake)
0375906 build: use loop-analysis over range-loop-analysis (fanquake)
12712fa build: remove -Wsign-compare (fanquake)

Pull request description:

  This remove the addition of flags that are already part of other options, such as `-Wall` or `-Wextra`; see each commit message for details. All of the flags being removed here already exist as part of `-Wall` as of GCC 8, or, for Clang, all exist in `-Wmost` (included in `-Wall)`, or as part of `-Wextra` as of Clang 7. Both of which are our minimum required compilers.

  Also cherry-picks one change from #21458.

  To give an example of how GCCs `-Wall` has changed over the last few releases:
  ### 11.x to trunk (12.x)
  Added:
  ```bash
  -Wzero-length-bounds
  -Wmismatched-dealloc
  -Wmismatched-new-delete (only for C/C++)
  ```

  ### 10.x to 11.x
  Added:
  ```bash
  -Warray-parameter=2 (C and Objective-C only)
  -Wrange-loop-construct (only for C++)
  -Wsizeof-array-div
  -Wvla-parameter (C and Objective-C only)
  ```

  Removed:
  ```bash
  -Wenum-conversion in C/ObjC;
  ```

  ### 9.x to 10.x
  Added:
  ```bash
  -Wenum-conversion in C/ObjC;
  -Wformat-overflow
  -Wformat-truncation
  -Wzero-length-bounds
  ```

  ### 8.x to 9.x
  Added:
  ```bash
  -Wpessimizing-move
  ```

  Removed:
  ```bash
  -Wstringop-truncation
  ```

  ### 7.x to 8.x
  Added:
  ```bash
  -Wcatch-value (C++ and Objective-C++ only)
  -Wmissing-attributes
  -Wmultistatement-macros
  -Wrestrict
  -Wsizeof-pointer-div
  -Wstringop-truncation
  ```

  [Clang Warning Options](https://clang.llvm.org/docs/DiagnosticsReference.html)
  [GCC Warning Options](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html)

ACKs for top commit:
  meshcollider:
    utACK aa69fd6

Tree-SHA512: 34dde6bd773c864202c151eaa35f902d03fb531c27fe5e1ef659225da03acade2efe5df56df3efb4df5bbded3d395348ce03c25b837fce83be53af3352f0f2bc
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 14, 2021
aa69fd6 build: Drop -Wno-unused-local-typedef (Hennadii Stepanov)
672e8c5 build: remove -Wunused-variable (fanquake)
5239af0 build: remove -Wswitch (fanquake)
0375906 build: use loop-analysis over range-loop-analysis (fanquake)
12712fa build: remove -Wsign-compare (fanquake)

Pull request description:

  This remove the addition of flags that are already part of other options, such as `-Wall` or `-Wextra`; see each commit message for details. All of the flags being removed here already exist as part of `-Wall` as of GCC 8, or, for Clang, all exist in `-Wmost` (included in `-Wall)`, or as part of `-Wextra` as of Clang 7. Both of which are our minimum required compilers.

  Also cherry-picks one change from bitcoin#21458.

  To give an example of how GCCs `-Wall` has changed over the last few releases:
  ### 11.x to trunk (12.x)
  Added:
  ```bash
  -Wzero-length-bounds
  -Wmismatched-dealloc
  -Wmismatched-new-delete (only for C/C++)
  ```

  ### 10.x to 11.x
  Added:
  ```bash
  -Warray-parameter=2 (C and Objective-C only)
  -Wrange-loop-construct (only for C++)
  -Wsizeof-array-div
  -Wvla-parameter (C and Objective-C only)
  ```

  Removed:
  ```bash
  -Wenum-conversion in C/ObjC;
  ```

  ### 9.x to 10.x
  Added:
  ```bash
  -Wenum-conversion in C/ObjC;
  -Wformat-overflow
  -Wformat-truncation
  -Wzero-length-bounds
  ```

  ### 8.x to 9.x
  Added:
  ```bash
  -Wpessimizing-move
  ```

  Removed:
  ```bash
  -Wstringop-truncation
  ```

  ### 7.x to 8.x
  Added:
  ```bash
  -Wcatch-value (C++ and Objective-C++ only)
  -Wmissing-attributes
  -Wmultistatement-macros
  -Wrestrict
  -Wsizeof-pointer-div
  -Wstringop-truncation
  ```

  [Clang Warning Options](https://clang.llvm.org/docs/DiagnosticsReference.html)
  [GCC Warning Options](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html)

ACKs for top commit:
  meshcollider:
    utACK aa69fd6

Tree-SHA512: 34dde6bd773c864202c151eaa35f902d03fb531c27fe5e1ef659225da03acade2efe5df56df3efb4df5bbded3d395348ce03c25b837fce83be53af3352f0f2bc
@fanquake
Copy link
Member

This needs a rebase, and comments addressed, or can probably be closed.

@hebasto hebasto closed this Nov 28, 2021
@hebasto hebasto deleted the 210317-error branch November 28, 2021 13:51
@bitcoin bitcoin locked and limited conversation to collaborators Nov 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants