unused and set but not used variable warnings when building with toolchain clang on Linux
Magnus Ihse Bursie
magnus.ihse.bursie at oracle.com
Tue Oct 8 13:38:49 UTC 2024
On 2024-10-07 16:45, Baesken, Matthias wrote:
> Hi, I came across some warnings as errors today when trying to build
> on Linux with toolchain clang (clang 15 on USE Linux) :
>
> jdk/src/jdk.jpackage/share/native/common/Log.cpp:46:28: error: unused
> variable 'defaultLogLevel' [-Werror,-Wunused-const-variable]
>
> const Logger::LogLevel defaultLogLevel = Logger::LOG_TRACE;
>
> jdk/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c:359:11:
> error: variable 'rslt' set but not used
> [-Werror,-Wunused-but-set-variable]
>
> int rslt;
>
> Should we adjust the coding ?
>
I'd say this sounds like the first hand choice: If the compiler is
indeed correct and this is dead code, remove it!
> Or somehow silence / remove this warning ?
>
> I wonder where this comes from, last time I built with clang on Linux
> I did not see those …
>
Unused code warnings in the JDK code base typically appears only for
debug or release builds, or some other #ifdef guards.
Neither Oracle CI nor GHA builds with clang on Linux on a regular basis.
I don't know if anyone else is doing it either. So that combination
typically bitrots over time.
/Magnus
> Best regards, Matthias
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/build-dev/attachments/20241008/c346b67e/attachment-0001.htm>
More information about the build-dev
mailing list