mfbt/double-conversion/use-static_assert.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mfbt/double-conversion/use-static_assert.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
     1.5 +--- a/mfbt/double-conversion/utils.h
     1.6 ++++ b/mfbt/double-conversion/utils.h
     1.7 +@@ -275,19 +275,18 @@ class StringBuilder {
     1.8 + // There is an additional use for BitCast.
     1.9 + // Recent gccs will warn when they see casts that may result in breakage due to
    1.10 + // the type-based aliasing rule.  If you have checked that there is no breakage
    1.11 + // you can use BitCast to cast one pointer type to another.  This confuses gcc
    1.12 + // enough that it can no longer see that you have cast one pointer type to
    1.13 + // another thus avoiding the warning.
    1.14 + template <class Dest, class Source>
    1.15 + inline Dest BitCast(const Source& source) {
    1.16 +-  // Compile time assertion: sizeof(Dest) == sizeof(Source)
    1.17 +-  // A compile error here means your Dest and Source have different sizes.
    1.18 +-  typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
    1.19 ++  static_assert(sizeof(Dest) == sizeof(Source),
    1.20 ++                "BitCast's source and destination types must be the same size");
    1.21 + 
    1.22 +   Dest dest;
    1.23 +   memmove(&dest, &source, sizeof(dest));
    1.24 +   return dest;
    1.25 + }
    1.26 + 
    1.27 + template <class Dest, class Source>
    1.28 + inline Dest BitCast(Source* source) {

mercurial