RFR: 8249945: Improve ARRAY_SIZE()

Lois Foltan lois.foltan at oracle.com
Thu Jul 23 15:09:56 UTC 2020


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.  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


More information about the hotspot-dev mailing list