RFR: 8339120: Use more fine-granular gcc unused warnings

Magnus Ihse Bursie ihse at openjdk.org
Wed Aug 28 11:28:19 UTC 2024


On Wed, 28 Aug 2024 06:38:48 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> We should make a similar set of changes for clang, though doing that in a separate
proposal is good. Is there a JBS issue for that yet?

Yes, we should. I am 80% done with that patch, but I have not yet opened a JBS ticket. Will do that now.

> make/autoconf/flags-cflags.m4 line 239:
> 
>> 237:       # Additional warnings that are not activated by -Wall and -Wextra
>> 238:       WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wreturn-type -Wsign-compare \
>> 239:           -Wtrampolines -Wundef -Wunused-const-variable -Wunused-function \
> 
> I think we don't want `-Wunused-const-variable=2` (eqv. `-Wunused-const-variable`) for C++
> code. Recall that C++ const variables default to internal linkage (e.g. implicitly static). It's normal
> to have a non-local constant in a header file that isn't used by every translation unit.  For C++ use
> `-Wunused-const-variable=1`.  I think doing this might eliminate the need for disabling this warning
> in a bunch of other places in this PR.

Good point, I'll try that.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20733#issuecomment-2315053230
PR Review Comment: https://git.openjdk.org/jdk/pull/20733#discussion_r1734501680


More information about the core-libs-dev mailing list