8377895: Create sizeof_auto, to reduce narrowing conversions#29716
Open
lkorinth wants to merge 1 commit intoopenjdk:masterfrom
Open
8377895: Create sizeof_auto, to reduce narrowing conversions#29716lkorinth wants to merge 1 commit intoopenjdk:masterfrom
lkorinth wants to merge 1 commit intoopenjdk:masterfrom
Conversation
`sizeof_auto` is created so that we can reduce the amount of casting and thus make the code more type safe. The normal `sizeof` will return a `size_t` although the size of most stuff can be represented in a `uint8_t`. `sizeof_auto` will return the size in an as small unsigned type as is possible. The result is that expressions that uses `sizeof_auto` can convert to most integral types, and no explicit narrowing cast will be needed.
|
👋 Welcome back lkorinth! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
3 tasks
stefank
reviewed
Feb 13, 2026
Member
stefank
left a comment
There was a problem hiding this comment.
I think the change looks good. The gtests doesn't compile everywhere so that needs to be fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sizeof_autois created so that we can reduce the amount of casting and thus make the code more type safe. The normalsizeofwill return asize_talthough the size of most stuff can be represented in auint8_t.sizeof_autowill return the size in an as small unsigned type as is possible. The result is that expressions that usessizeof_autocan convert to most integral types, and no explicit narrowing cast will be needed.The change in
cpCache.hppis an example where we would get an implicit narrowing warning (if we had those enabled) using normalsizeof, but wheresizeof_autowill not make the expression asize_t.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29716/head:pull/29716$ git checkout pull/29716Update a local copy of the PR:
$ git checkout pull/29716$ git pull https://git.openjdk.org/jdk.git pull/29716/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 29716View PR using the GUI difftool:
$ git pr show -t 29716Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29716.diff
Using Webrev
Link to Webrev Comment