mfbt/double-conversion/use-static_assert.patch
author Nicholas Nethercote <nnethercote@mozilla.com>
Fri, 20 Feb 2015 13:13:16 +1100
changeset 250342 20306323469e9b9f4f36735a72e82ed4cdf01e1b
parent 163015 4d4a7fd7d375a9f711d508c3938339e7228a28e7
child 378420 89b895c219f2b97fc0ded8877b30c337e697bdaa
permissions -rw-r--r--
Bug 1134030 - Add WindowsAddressSpaceReporter. code=njn,dmajor. r=dmajor,njn. a=lsblakk.

diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
--- a/mfbt/double-conversion/utils.h
+++ b/mfbt/double-conversion/utils.h
@@ -275,19 +275,18 @@ class StringBuilder {
 // There is an additional use for BitCast.
 // Recent gccs will warn when they see casts that may result in breakage due to
 // the type-based aliasing rule.  If you have checked that there is no breakage
 // you can use BitCast to cast one pointer type to another.  This confuses gcc
 // enough that it can no longer see that you have cast one pointer type to
 // another thus avoiding the warning.
 template <class Dest, class Source>
 inline Dest BitCast(const Source& source) {
-  // Compile time assertion: sizeof(Dest) == sizeof(Source)
-  // A compile error here means your Dest and Source have different sizes.
-  typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
+  static_assert(sizeof(Dest) == sizeof(Source),
+                "BitCast's source and destination types must be the same size");
 
   Dest dest;
   memmove(&dest, &source, sizeof(dest));
   return dest;
 }
 
 template <class Dest, class Source>
 inline Dest BitCast(Source* source) {