When trying the GCC static analyzer (-fanalyzer flag)
diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index e80d9a98957..9d1ae60047b 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -610,7 +610,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], # CFLAGS WARNINGS STUFF # Set JVM_CFLAGS warning handling if test "x$TOOLCHAIN_TYPE" = xgcc; then - WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS" + # enable -fanalyzer (but better only for gcc12 + , and also only for C) + # too many strange / shaky fd leak warnings + WARNING_CFLAGS_JDK_CONLY="-fanalyzer -Wno-analyzer-fd-leak $WARNINGS_ENABLE_ALL_CFLAGS" WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS" WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL_CXXFLAGS" I noticed that the WARNING_CFLAGS_JDK_CONLY go into the hotspot jtreg tests, e.g. : /jdk/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarfHelper.h:46:6: error: dereference of NULL '0' [CWE-476] [-Werror=analyzer-null-dereference] 46 | *x = 34; // Crash | ~~~^~~~ 'dereference_null': event 1 | | 46 | *x = 34; // Crash | | ~~~^~~~ | | | | | (1) dereference of NULL '0' This might be intended but I was surprised that the HS C tests take WARNING_CFLAGS_JDK_CONLY !? Is this intended or not ? Best regards, Matthias