JDK-8367051 : Build failure with clang on linux and AIX after switch to C++17
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 26
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-09-08
  • Updated: 2025-12-07
  • Resolved: 2025-09-09
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 26
26 b15Fixed
Related Reports
Causes :  
Duplicate :  
Duplicate :  
Relates :  
Description
After JDK-8314488 (using C++17) we get build failures on linux when using clang as the compiler.  For example:

{@code}
/usr/include/stdio.h:352:12: error: exception specification in declaration does not match previous declaration
  352 | extern int sprintf (char *__restrict __s,
      |            ^
/home/kab/gitsb/forbid-sprintf-warning/jdk/open/src/hotspot/share/utilities/forbiddenFunctions.hpp:61:23: note: previous declaration is here
   61 | FORBID_C_FUNCTION(int sprintf(char*, const char*, ...), "use os::snprintf");
      |                       ^
{@code}

Comments
Changeset: b653ae92 Branch: master Author: Kim Barrett <kbarrett@openjdk.org> Date: 2025-09-09 15:02:54 +0000 URL: https://git.openjdk.org/jdk/commit/b653ae92d5941202780873fad1a7cefd51e4e7a8
09-09-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/27154 Date: 2025-09-09 01:00:30 +0000
09-09-2025

As a temporary measure I was going to disable forbidding for clang, but [~ayang] suggestion seems better, so I'll go with that. Then need to figure out what to do about this for real.
08-09-2025

Build breakage. No workaround. Setting to P1.
08-09-2025

> Adding some includes to `forbiddenFunctions.hpp` can make clang see the declarations with right exception first, thus working again The fix suggested by [~ayang] works on AIX too.
08-09-2025

We see similar build errors on AIX : /usr/include/stdio.h:336:21: error: exception specification in declaration does not match previous declaration 336 | extern int _NOTHROW(vsnprintf, (char *__restrict__, size_t, const char *__restrict__, va_list)); | ^ /jdk/src/hotspot/share/utilities/forbiddenFunctions.hpp:67:23: note: previous declaration is here 67 | FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), "use os::vsnprintf"); |
08-09-2025

Adding some includes to `forbiddenFunctions.hpp` can make clang see the declarations with right exception first, thus working again. Just fyi. ``` #ifdef __clang__ #include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <wchar.h> #endif ```
08-09-2025