RFR: 8240615: is_power_of_2() has Undefined Behaviour and is inconsistent
Claes Redestad
claes.redestad at oracle.com
Thu Mar 5 18:42:30 UTC 2020
On 2020-03-05 19:23, Stefan Karlsson wrote:
> You used std::numeric_limits<T>::min() in the test. There's a comment in
> powerOfTwo.hpp stating:
>
> // Helper function to get the maximum positive value. Implemented here
> // since using std::numeric_limits<T>::max() seems problematic on some
> // platforms.
>
> I don't know if this means that min() is problematic as well?
Me neither, but I think for test use it should be fine. There are some
uses of ::max() in a few gtests already.
For context I saw Solaris slowdebug builds fail when implementing
powerOfTwo with use of std::numeric_limits. The build issue appeared
only in slowdebug builds when numeric_limits was used in code that get
heavily inlined, causing some linking issue.
/Claes
More information about the hotspot-runtime-dev
mailing list