JDK-8253548 : jvmFlagAccess.cpp: clang 9.0.0 format specifier error
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-09-23
  • Updated: 2020-10-05
  • Resolved: 2020-09-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b18Fixed
Related Reports
Relates :  
Description
Reported by Matthias Baesken

After JDK-8081833

./src/hotspot/share/runtime/flags/jvmFlagAccess.cpp:250:82: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]

    st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", size_t(0), SIZE_MAX);
/usr/include/stdint.h:153:20: note: expanded from macro 'SIZE_MAX'
#define SIZE_MAX          UINT64_MAX
/usr/include/stdint.h:87:27: note: expanded from macro 'UINT64_MAX'
#define UINT64_MAX        18446744073709551615ULL

======
checking for clang... /usr/bin/clang
checking resolved symbolic links for CC... no symlink
configure: Using clang C compiler version 9.0.0 [Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin]
checking whether the C compiler works... yes
checking for clang++... /usr/bin/clang++
checking resolved symbolic links for CXX... no symlink
configure: Using clang C++ compiler version 9.0.0 [Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin]
Comments
Changeset: b1ce6bdb Author: Ioi Lam <iklam@openjdk.org> Date: 2020-09-29 15:17:34 +0000 URL: https://git.openjdk.java.net/jdk/commit/b1ce6bdb
29-09-2020

Apparently for older clang, SIZE_MAX is not of size_t type. A similar type cast is needed here: https://github.com/openjdk/jdk/blame/efd10546865998028aa6d34cf939ca0de67a90fc/hotspot/src/share/vm/logging/logFileOutput.cpp#L194
25-09-2020

Ioi suggested a fix that adds a cast ; this makes the error go away with clang C++ compiler version 9.0.0 . diff --git a/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp b/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp index 56d752d337d..07ff6b1546e 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagAccess.cpp @@ -247,7 +247,7 @@ public: st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", min, max); } void print_default_range(outputStream* st) const { - st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", size_t(0), SIZE_MAX); + st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", size_t(0), size_t(SIZE_MAX)); } };
24-09-2020

This failure didn't appear with clang version 11.0.0 used by our CI.
23-09-2020