RFR: 8377895: Create sizeof_auto, to reduce narrowing conversions [v7]

Kim Barrett kbarrett at openjdk.org
Fri Feb 20 06:49:54 UTC 2026


On Fri, 20 Feb 2026 05:07:41 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Leo Korinth has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Line break comments, and add compiler error code on Windows to comment
>
> src/hotspot/share/utilities/globalDefinitions.hpp line 179:
> 
>> 177:         std::conditional_t<N <= std::numeric_limits<uint32_t>::max(), uint32_t, uint64_t>>>;
>> 178:   return static_cast<unsigned_auto>(N);
>> 179: }
> 
> This function doesn't really have anything to do with sizeof, does it?  Well, except that it is unsigned.  This could be named something like smallest_type_for_constant, narrow_const, etc.  It is conceivable that in the future we might want something like this for signed values as well.

I think that it can be renamed or otherwise adjusted later if someone comes up
with other use-cases. But for now, it is provided as nothing more than
supporting the implementation of sizeof_auto.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29716#discussion_r2831661293


More information about the hotspot-dev mailing list