Bug 1189967 - Avoid including <string> from Char16.h. r=nfroyd
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 21 Aug 2015 16:05:40 +0900
changeset 291533 6fa4f576849106db60b470ba3fe87cbe0c22d161
parent 291532 73bd8b894c6bf6b07b4a94afb87af187d013c5aa
child 291534 3cb2f2b870f4c256dccc8647a2e1e4616c244fda
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1189967
milestone43.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 1189967 - Avoid including <string> from Char16.h. r=nfroyd Since Char16.h is included everywhere, and MSVC 2015 uses the char16ptr_t trick it contains, we include <string> everywhere, but that has the side effect of breaking the build in subtle ways. One way around this would be to avoid including Char16.h in the first place, but that requires more work than I was ready to put in. So instead, just avoid including <string> by removing the conversion operator for std::wstring.
mfbt/Char16.h
mfbt/Compression.cpp
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -44,17 +44,17 @@ typedef unsigned int char32_t;
     */
 #  define MOZ_CHAR16_IS_NOT_WCHAR
 #  ifdef WIN32
 #    define MOZ_USE_CHAR16_WRAPPER
 #  endif
 #endif
 
 #ifdef MOZ_USE_CHAR16_WRAPPER
-# include <string>
+# include <cstdint>
   /**
    * Win32 API extensively uses wchar_t, which is represented by a separated
    * builtin type than char16_t per spec. It's not the case for MSVC prior to
    * MSVC 2015, but other compilers follow the spec. We want to mix wchar_t and
    * char16_t on Windows builds. This class is supposed to make it easier. It
    * stores char16_t const pointer, but provides implicit casts for wchar_t as
    * well. On other platforms, we simply use
    * |typedef const char16_t* char16ptr_t|. Here, we want to make the class as
@@ -88,20 +88,16 @@ public:
   operator const void*() const
   {
     return mPtr;
   }
   operator bool() const
   {
     return mPtr != nullptr;
   }
-  operator std::wstring() const
-  {
-    return std::wstring(static_cast<const wchar_t*>(*this));
-  }
 
   /* Explicit cast operators to allow things like (char16_t*)str. */
   explicit operator char16_t*() const
   {
     return const_cast<char16_t*>(mPtr);
   }
   explicit operator wchar_t*() const
   {
--- a/mfbt/Compression.cpp
+++ b/mfbt/Compression.cpp
@@ -2,16 +2,21 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Compression.h"
 #include "mozilla/CheckedInt.h"
 
+// Without including <string>, MSVC 2015 complains about e.g. the impossibility
+// to convert `const void* const` to `void*` when calling memchr from
+// corecrt_memory.h.
+#include <string>
+
 using namespace mozilla::Compression;
 
 namespace {
 
 #include "lz4.c"
 
 }/* anonymous namespace */