Hi, please consider the following changes:
This PR re-enables stringop-overflow warnings.
It was assumed that the assert in `Thread::current()`, which calls the
`ATTRIBUTE_NORETURN` report function on failure, would be sufficient to inform
the GCC compiler that the current thread is always non-null. However, it turns
out that the assert is weakened by the `DebuggingContext`:
Instead of having
`assert(current != nullptr, "Thread::current() called on detached thread");`
in fact one gets this:
`if ( !(DebuggingContext::is_enabled() || current != null) ) {
report_vm_error(...); }`
If `DebuggingContext` is enabled then the error will not be triggered
regardless of what `current` is. This makes GCC consider the virtually
impossible path and emit false positive warnings about atomics.
The same problem is found in the Shenandoah code.
The fix is to strengthen the assertion by
`DEBUG_ONLY(guarantee(current != nullptr, "...");)`
which removes the assertion completely in product builds, but for debug builds
makes it clear for the compiler that the operand cannot be nullptr.
With this findings I conclude that it is not a compiler bug.
Tested in tiers 1-5 and GHA.
Separate builds with Shenandoah done.
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- Re-enabled stringop overflow warnings.
Changes: https://git.openjdk.org/jdk/pull/31025/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31025&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8320353
Stats: 18 lines in 5 files changed: 8 ins; 7 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/31025.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/31025/head:pull/31025
PR: https://git.openjdk.org/jdk/pull/31025