summaryrefslogtreecommitdiffstats
path: root/luni/src/main/native
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-04-16 15:06:36 -0700
committerDan Albert <danalbert@google.com>2015-04-27 10:28:52 -0700
commit92d6ba31a225d55ab65a0ede80310d91f3f52c30 (patch)
tree29ffbb517e027be7ef3391e6458ea921a53dfa52 /luni/src/main/native
parent8b7dbadede97a5166fcddfe6783e89c8957c1830 (diff)
downloadlibcore-92d6ba31a225d55ab65a0ede80310d91f3f52c30.zip
libcore-92d6ba31a225d55ab65a0ede80310d91f3f52c30.tar.gz
libcore-92d6ba31a225d55ab65a0ede80310d91f3f52c30.tar.bz2
Ensure proper integer promotion for bit shifts.
Previously this was a 32-bit value being shifted up to 63 bits, which is undefined behavior. Change-Id: I99bb38508937f7a33d5c2c841b7cc32d5f374ef9
Diffstat (limited to 'luni/src/main/native')
-rw-r--r--luni/src/main/native/java_lang_RealToString.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/luni/src/main/native/java_lang_RealToString.cpp b/luni/src/main/native/java_lang_RealToString.cpp
index 7036fe8..9b412b5 100644
--- a/luni/src/main/native/java_lang_RealToString.cpp
+++ b/luni/src/main/native/java_lang_RealToString.cpp
@@ -80,7 +80,7 @@ void RealToString_bigIntDigitGenerator(JNIEnv* env, jobject obj, jlong f, jint e
*R = f;
*mplus = *mminus = 1;
simpleShiftLeftHighPrecision (mminus, RM_SIZE, e);
- if (f != (2 << (p - 1)))
+ if (f != (INT64_C(1) << p))
{
simpleShiftLeftHighPrecision (R, RM_SIZE, e + 1);
*S = 2;
@@ -103,7 +103,7 @@ void RealToString_bigIntDigitGenerator(JNIEnv* env, jobject obj, jlong f, jint e
}
else
{
- if (isDenormalized || (f != (2 << (p - 1))))
+ if (isDenormalized || (f != (INT64_C(1) << p)))
{
*R = f << 1;
*S = 1;