mfbt/double-conversion/use-static_assert.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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