On Wed, 9 Oct 2024 11:44:35 GMT, Matthias Baesken <mbaes...@openjdk.org> wrote:

>> There are a few warnings as errors occurring when building on Linux with 
>> clang (clang15). Mostly these are some kind of 'unused' warnings.
>> Might be related to https://bugs.openjdk.org/browse/JDK-8339156 .
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   adjust gcc warning settings; bring back rslt

test/hotspot/gtest/runtime/test_os_linux.cpp line 366:

> 364:       os::pretouch_memory(heap, heap + size, os::vm_page_size());
> 365:     };
> 366:     auto useMemory = [heap](Thread*, int) {

Coming to this late, after the change has been integrated.

These lambdas should have been changed to use implicit reference capture
(`[&]`), per the style guide.

The change to the pretouch lambda actually makes things more difficult to
understand, since the outer `size` variable *is* referenced within the lambda
body.  This works because `size` is an integral constant initialized from a
constant expression, so does not need to be captured for the reference to
work. I'm guessing the clang warning had something to do with that, but it's
not mentioned in the JBS issue.  If implicit reference capture were used, the
referential transparency that comes with it would mean readers wouldn't need
to even know about that distinction.

I'll file an issue to change the capture lists.  I didn't find any other
explicit capture lists in HotSpot code.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21407#discussion_r1796392834

Reply via email to