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