RFR: 8249945: Improve ARRAY_SIZE()
Kim Barrett
kim.barrett at oracle.com
Thu Jul 23 19:45:09 UTC 2020
> On Jul 23, 2020, at 11:09 AM, Lois Foltan <lois.foltan at oracle.com> wrote:
>
> On 7/23/2020 3:31 AM, Kim Barrett wrote:
>> Please review this reimplementation of the ARRAY_SIZE() macro. The
>> new implementation rejects pointer types instead of quietly returning
>> the wrong value; see the CR for more details.
>>
>> CR:
>> https://bugs.openjdk.java.net/browse/JDK-8249945
>>
>> Webrev:
>> https://cr.openjdk.java.net/~kbarrett/8249945/open.00/
>>
>> Testing:
>> mach5 tier1
>>
>
> Hi Kim,
>
> Looks good.
Thanks.
> For my own understanding, is there any value in adding a "const" in front of T in the template? Such as
>
> template<typename T, size_t N> char (&array_size_impl(const T (&)[N]))[N];
>
> Thanks,
> Lois
I think it doesn’t matter; if the argument is const, the deduced T will be const qualified. But we don’t care
about the details of the deduced T at all. The last of the new gtest checks uses a const array argument.
More information about the hotspot-dev
mailing list