mfbt/double-conversion/use-static_assert.patch

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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