RFR: 8328934: Assert that ABS input and output are legal [v3]

Andrew Haley aph at openjdk.org
Fri Apr 12 22:11:46 UTC 2024


On Fri, 12 Apr 2024 16:05:10 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> > ```
> >   T res = (x < 0 && x != std::numeric_limits<T>::min()) ? -x : x;
> > ```
> 
> I mean, we catch the proper error in some tests: https://bugs.openjdk.org/browse/JDK-8330158 Do we really need to do this `x != std::numeric_limits<T>::min()` dance here?

I think so. Several of us have worked on eliminating undefined behaviour in HotSpot and we've made good progress. I think it would be sad for new UB to be pushed now, especially in a case like this when it wouldn't be accidental. UB is just something we have to deal with, because C++. :-(

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

PR Comment: https://git.openjdk.org/jdk/pull/18751#issuecomment-2052623059


More information about the hotspot-dev mailing list