Bug 859257 - Mark DoublePun values in ToIntWidth as volatile to work around a Clang bug. r=jwalden
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 12 Apr 2013 14:16:57 +0200
changeset 128586 4c0d13ce4c4a208afd1b778543883bb4c9d5db18
parent 128585 93f9dc06b4c5457ed0e6bbf929c0aafd2ceb34e5
child 128587 25323c442d1adf6320d69f57310439fcac1425e3
push id24532
push userryanvm@gmail.com
push dateFri, 12 Apr 2013 19:06:49 +0000
treeherdermozilla-central@2aff2d574a1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs859257
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 859257 - Mark DoublePun values in ToIntWidth as volatile to work around a Clang bug. r=jwalden
js/src/vm/NumericConversions.h
--- a/js/src/vm/NumericConversions.h
+++ b/js/src/vm/NumericConversions.h
@@ -35,17 +35,23 @@ union DoublePun {
 
 /* Numeric Conversion base. Round doubles to Ints according to ECMA or WEBIDL standards. */
 template<size_t width, typename ResultType>
 inline ResultType
 ToIntWidth(double d)
 {
 #if defined(__i386__) || defined(__i386) || defined(__x86_64__) || \
     defined(_M_IX86) || defined(_M_X64)
+
+#ifdef __clang__
+    /* volatile to keep Clang from miscompiling, see bug 859257. */
+    volatile detail::DoublePun du, duh, twoWidth;
+#else
     detail::DoublePun du, duh, twoWidth;
+#endif
     uint32_t di_h, u_tmp, expon, shift_amount;
     int32_t mask32;
 
     /*
      * Algorithm Outline
      *  Step 1. If d is NaN, +/-Inf or |d|>=2^(width + 52) or |d|<1, then return 0
      *          All of this is implemented based on an exponent comparison,
      *          since anything with a higher exponent is either not finite, or