|
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"); |
|
18 |
|
19 Dest dest; |
|
20 memmove(&dest, &source, sizeof(dest)); |
|
21 return dest; |
|
22 } |
|
23 |
|
24 template <class Dest, class Source> |
|
25 inline Dest BitCast(Source* source) { |