RFR: 8377895: Create sizeof_auto, to reduce narrowing conversions [v7]
Dean Long
dlong at openjdk.org
Fri Feb 20 22:35:48 UTC 2026
On Fri, 20 Feb 2026 06:47:24 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> 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.
OK, so we'll end up with different macros sizeof_auto() and xyz_auto() instead of allowing something more general like auto_size(xyz()) at the call site?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29716#discussion_r2835359748
More information about the hotspot-dev
mailing list