mfbt/double-conversion/use-static_assert.patch

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial