hg: jdk7/hotspot-comp/hotspot: 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
Florian Weimer
fw at deneb.enyo.de
Sat Dec 27 13:28:15 PST 2008
* vladimir kozlov:
> 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
> Summary: Replaces SharedRuntime::f2i et al with versions that should work
This:
JRT_LEAF(jlong, SharedRuntime::f2l(jfloat x))
- if (g_isnan(x)) {return 0;}
- jlong lltmp = (jlong)x;
- if (lltmp != min_jlong) {
- return lltmp;
- } else {
- if (x < 0) {
- return min_jlong;
- } else {
- return max_jlong;
- }
- }
+ if (g_isnan(x))
+ return 0;
+ if (x >= (jfloat) max_jlong)
+ return max_jlong;
+ if (x <= (jfloat) min_jlong)
+ return min_jlong;
+ return (jlong) x;
JRT_END
doesn't look right because
(jfloat) max_jlong and (jfloat) min_jlong
are not fully specified, either (they can be off by one, and so the
comparison could be false even if the subsequent cast is undefined).
More information about the hotspot-compiler-dev
mailing list