mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 919337: Use static_assert in double_conversion::BitCast. r=waldo
This commit is contained in:
parent
755922ca39
commit
189d59bfb0
@ -19,3 +19,4 @@ cp $1/src/*.cc ./
|
||||
patch -p3 < add-mfbt-api-markers.patch
|
||||
patch -p3 < use-StandardInteger.patch
|
||||
patch -p3 < use-mozilla-assertions.patch
|
||||
patch -p3 < use-static_assert.patch
|
||||
|
25
mfbt/double-conversion/use-static_assert.patch
Normal file
25
mfbt/double-conversion/use-static_assert.patch
Normal file
@ -0,0 +1,25 @@
|
||||
diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
|
||||
--- a/mfbt/double-conversion/utils.h
|
||||
+++ b/mfbt/double-conversion/utils.h
|
||||
@@ -275,19 +275,18 @@ class StringBuilder {
|
||||
// There is an additional use for BitCast.
|
||||
// Recent gccs will warn when they see casts that may result in breakage due to
|
||||
// the type-based aliasing rule. If you have checked that there is no breakage
|
||||
// you can use BitCast to cast one pointer type to another. This confuses gcc
|
||||
// enough that it can no longer see that you have cast one pointer type to
|
||||
// another thus avoiding the warning.
|
||||
template <class Dest, class Source>
|
||||
inline Dest BitCast(const Source& source) {
|
||||
- // Compile time assertion: sizeof(Dest) == sizeof(Source)
|
||||
- // A compile error here means your Dest and Source have different sizes.
|
||||
- typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
|
||||
+ static_assert(sizeof(Dest) == sizeof(Source),
|
||||
+ "BitCast's source and destination types must be the same size");
|
||||
|
||||
Dest dest;
|
||||
memmove(&dest, &source, sizeof(dest));
|
||||
return dest;
|
||||
}
|
||||
|
||||
template <class Dest, class Source>
|
||||
inline Dest BitCast(Source* source) {
|
@ -280,9 +280,8 @@ class StringBuilder {
|
||||
// another thus avoiding the warning.
|
||||
template <class Dest, class Source>
|
||||
inline Dest BitCast(const Source& source) {
|
||||
// Compile time assertion: sizeof(Dest) == sizeof(Source)
|
||||
// A compile error here means your Dest and Source have different sizes.
|
||||
typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
|
||||
static_assert(sizeof(Dest) == sizeof(Source),
|
||||
"BitCast's source and destination types must be the same size");
|
||||
|
||||
Dest dest;
|
||||
memmove(&dest, &source, sizeof(dest));
|
||||
|
Loading…
Reference in New Issue
Block a user