Alexander Pyhalov
2013-12-26 19364bc98e54de97ee80f4a687e3aa42d547eced
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp
index 763d6e6..8b04fc8 100644
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1023,6 +1023,19 @@ static JS_ALWAYS_INLINE TargetType Convert(FromType d)
   return ConvertImpl<TargetType, FromType>::Convert(d);
 }
 
+template<class Type>
+class no_bug_numeric_digits
+{
+  public:
+    static const int digits = numeric_limits<Type>::digits;
+};
+template<>
+class no_bug_numeric_digits<unsigned long long>
+{
+  public:
+    static const int digits = 64;
+};
+
 template<class TargetType, class FromType>
 static JS_ALWAYS_INLINE bool IsAlwaysExact()
 {
@@ -1035,7 +1048,7 @@ static JS_ALWAYS_INLINE bool IsAlwaysExact()
   // 2) If FromType is signed, TargetType must also be signed. (Floating point
   //    types are always signed.)
   // 3) If TargetType is an exact integral type, FromType must be also.
-  if (numeric_limits<TargetType>::digits < numeric_limits<FromType>::digits)
+  if (numeric_limits<TargetType>::digits < no_bug_numeric_digits<FromType>::digits)
     return false;
 
   if (numeric_limits<FromType>::is_signed &&