RFR: 8320353: Reenable stringop-overflow warnings
Julian Waters
jwaters at openjdk.org
Wed Jul 2 09:12:40 UTC 2025
On Tue, 1 Jul 2025 12:25:04 GMT, Anton Artemov <duke at openjdk.org> wrote:
> Hi, please consider the following changes:
>
> this PR addresses the issue of stringop-overflow warnings produced by GCC. The compiler does think that the thread pointer returned by `JavaThread::current()` can be null, though it cant. The thread pointer ends up being an argument in `__atomic_load`, and the compiler reports the warning related to argument of that method.
>
> The patch adds a hint to the compiler by means of `__builtin_unreachable()` intrinsic, which tells the compiler that certain piece of code will never be reached (case of thread pointer being null). This solves the issue.
>
> Tested in tiers 1-3 and GHA.
A less messy solution could be to use PRAGMA_STRINGOP_OVERFLOW_IGNORED instead. The conditionals for the PRAGMA IGNORED macros are already all handled for you, so there's no need to put conditionalizations at the use sites. As an example, simply do the following:
PRAGMA_DIAG_PUSH
PRAGMA_STRINGOP_OVERFLOW_IGNORED
// Problem code here
PRAGMA_DIAG_POP
The first 2 macros are placed directly in front of the problem code, and the last goes behind.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26067#issuecomment-3027075027
More information about the build-dev
mailing list