RFR: 8314488: Compiling the JDK with C++17

Kim Barrett kbarrett at openjdk.org
Sat Aug 16 11:48:13 UTC 2025


On Sat, 16 Aug 2025 09:17:28 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> I'm hijacking the PR mechanism as a way to discuss new C++17 features that can
>> be more easily structured and captured than bare email. Once discussion
>> settles down I'll turn the results into HotSpot Style Guide changes. I don't
>> intend to integrate any version of this document to the OpenJDK repository.
>
> doc/cpp17-features.md line 440:
> 
>> 438: use of the library function `std::as_const`. But explicit capture parameters
>> 439: are recommended against in HotSpot. `FORBIDDEN_ROI`.
>> 440: 
> 
> How did we get from "recommended against" to `FORBIDDEN_ROI`?

I used the wrong feature here. Explicit capture parameters are (I think fairly
strongly) recommended against. But capture initializers are explicitly
forbidden, and using `std::as_const` in this way involves the latter.

This functionality might be worth having for other reasons. However, the
implementation of `std::as_const` looks sufficiently simple that adding an
equivalent to (say) globalDefinitions.hpp might be appropriate, rather than
dragging in all of `<utility>` (with all that would entail) for that one
little function. (We already do that for `declval`, for example.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25992#discussion_r2280391522


More information about the hotspot-dev mailing list