Bug 1596572 - make CompareStringInfinityOrNaN work with clang 5.x and C++17; r=jandem
authorNathan Froyd <froydnj@mozilla.com>
Fri, 15 Nov 2019 10:29:33 +0000
changeset 502173 6c468a5b599635fc091ea77b888283ada23abfae
parent 502172 7b0f2fb77033c4eb66cd8ffbfdf7dcc52b7802eb
child 502174 0860d7cbadd429f0bee361d5e389dd61ef5e54ad
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1596572, 1579189
milestone72.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 1596572 - make CompareStringInfinityOrNaN work with clang 5.x and C++17; r=jandem clang 5.x (which is now our minimum supported clang version as of bug 1579189) doesn't quite work with inline variables and C++17. Fortunately, we can make some straightforward changes to make the code for `CompareStringInfinityOrNan` work in such situations. Differential Revision: https://phabricator.services.mozilla.com/D53082
js/src/vm/TypedArrayObject.cpp
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -2296,32 +2296,31 @@ bool js::IsBufferSource(JSObject* object
 }
 
 template <typename CharT>
 struct CompareStringInfinityOrNaN;
 
 template <>
 struct CompareStringInfinityOrNaN<Latin1Char> {
   using CharTraitT = char;
-  static constexpr char Infinity[] = "Infinity";
-  static constexpr char NaN[] = "NaN";
+  static const char Infinity[];
+  static const char NaN[];
 };
 
 template <>
 struct CompareStringInfinityOrNaN<char16_t> {
   using CharTraitT = char16_t;
-  static constexpr char16_t Infinity[] = u"Infinity";
-  static constexpr char16_t NaN[] = u"NaN";
+  static const char16_t Infinity[];
+  static const char16_t NaN[];
 };
 
-// These definitions can be removed when we compile with C++17.
-constexpr char CompareStringInfinityOrNaN<Latin1Char>::Infinity[];
-constexpr char CompareStringInfinityOrNaN<Latin1Char>::NaN[];
-constexpr char16_t CompareStringInfinityOrNaN<char16_t>::Infinity[];
-constexpr char16_t CompareStringInfinityOrNaN<char16_t>::NaN[];
+const char CompareStringInfinityOrNaN<Latin1Char>::Infinity[] = "Infinity";
+const char CompareStringInfinityOrNaN<Latin1Char>::NaN[] = "NaN";
+const char16_t CompareStringInfinityOrNaN<char16_t>::Infinity[] = u"Infinity";
+const char16_t CompareStringInfinityOrNaN<char16_t>::NaN[] = u"NaN";
 
 template <typename CharT>
 static inline bool StringIsInfinity(mozilla::Range<const CharT> s) {
   using CharTraitT = typename CompareStringInfinityOrNaN<CharT>::CharTraitT;
   constexpr auto Infinity = CompareStringInfinityOrNaN<CharT>::Infinity;
   // Can be changed to constexpr when compiled with C++17.
   size_t length = std::char_traits<CharTraitT>::length(Infinity);