RFR: 8347649: Build fails by clang17 after JDK-8313396

SendaoYan syan at openjdk.org
Tue Jan 14 12:56:50 UTC 2025


Hi all,
This PR fix build failure by clang17 after JDK-8313396. Before this PR file src/hotspot/share/utilities/forbiddenFunctions.hpp `#include <stdlib.h>` and then  `#include "forbiddenFunctions_posix.hpp"`. System header file <stdlib.h> define `realpath` function, and file forbiddenFunctions_posix.hpp add attribute declaration for `realpath` function, so clang17 report compile warning "attribute declaration must precede definition". This PR switch the sequence of `#include <stdlib.h>` and `#include "forbiddenFunctions_posix.hpp"` in file src/hotspot/share/utilities/forbiddenFunctions.hpp to fix this compile warning issue.

Below code snippet shows the clang17 compile waning:

void a(const char *, char *){};
[[deprecated]] void a(const char *, char *);


clang -Wall -c ~/compiler-test/zzkk/attribute.cpp
/home/yansendao/compiler-test/zzkk/attribute.cpp:5:3: warning: attribute declaration must precede definition [-Wignored-attributes]
    5 | [[deprecated]] void a(const char *, char *);
      |   ^
/home/yansendao/compiler-test/zzkk/attribute.cpp:4:6: note: previous definition is here
    4 | void a(const char *, char *){};
      |      ^
1 warning generated.


Additional testing:

- [ ] configure and make with gcc10 with release/fastdebug debug level
- [ ] configure and make with gcc14 with release/fastdebug debug level

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

Commit messages:
 - 8347649: Build fails by clang17 after JDK-8313396

Changes: https://git.openjdk.org/jdk/pull/23102/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23102&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347649
  Stats: 8 lines in 1 file changed: 4 ins; 4 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/23102.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23102/head:pull/23102

PR: https://git.openjdk.org/jdk/pull/23102


More information about the hotspot-dev mailing list