| Index: src/base/macros.h
|
| diff --git a/src/base/macros.h b/src/base/macros.h
|
| index f47b0b9d55c82ff68c70c00cad6edee4cb479778..f904f529fd4bdcb1efc8077f9f560a51eedf4da6 100644
|
| --- a/src/base/macros.h
|
| +++ b/src/base/macros.h
|
| @@ -102,66 +102,6 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
|
| #endif // V8_OS_NACL
|
|
|
|
|
| -// The COMPILE_ASSERT macro can be used to verify that a compile time
|
| -// expression is true. For example, you could use it to verify the
|
| -// size of a static array:
|
| -//
|
| -// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
|
| -// content_type_names_incorrect_size);
|
| -//
|
| -// or to make sure a struct is smaller than a certain size:
|
| -//
|
| -// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
|
| -//
|
| -// The second argument to the macro is the name of the variable. If
|
| -// the expression is false, most compilers will issue a warning/error
|
| -// containing the name of the variable.
|
| -#if V8_HAS_CXX11_STATIC_ASSERT
|
| -
|
| -// Under C++11, just use static_assert.
|
| -#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
|
| -
|
| -#else
|
| -
|
| -template <bool>
|
| -struct CompileAssert {};
|
| -
|
| -#define COMPILE_ASSERT(expr, msg) \
|
| - typedef CompileAssert<static_cast<bool>(expr)> \
|
| - msg[static_cast<bool>(expr) ? 1 : -1] ALLOW_UNUSED_TYPE
|
| -
|
| -// Implementation details of COMPILE_ASSERT:
|
| -//
|
| -// - COMPILE_ASSERT works by defining an array type that has -1
|
| -// elements (and thus is invalid) when the expression is false.
|
| -//
|
| -// - The simpler definition
|
| -//
|
| -// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
|
| -//
|
| -// does not work, as gcc supports variable-length arrays whose sizes
|
| -// are determined at run-time (this is gcc's extension and not part
|
| -// of the C++ standard). As a result, gcc fails to reject the
|
| -// following code with the simple definition:
|
| -//
|
| -// int foo;
|
| -// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
|
| -// // not a compile-time constant.
|
| -//
|
| -// - By using the type CompileAssert<static_cast<bool>(expr)>, we ensure that
|
| -// expr is a compile-time constant. (Template arguments must be
|
| -// determined at compile-time.)
|
| -//
|
| -// - The array size is (static_cast<bool>(expr) ? 1 : -1), instead of simply
|
| -//
|
| -// ((expr) ? 1 : -1).
|
| -//
|
| -// This is to avoid running into a bug in MS VC 7.1, which
|
| -// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
|
| -
|
| -#endif
|
| -
|
| -
|
| // bit_cast<Dest,Source> is a template function that implements the
|
| // equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in
|
| // very low-level functions like the protobuf library and fast math
|
| @@ -217,8 +157,8 @@ struct CompileAssert {};
|
| // is likely to surprise you.
|
| template <class Dest, class Source>
|
| V8_INLINE Dest bit_cast(Source const& source) {
|
| - COMPILE_ASSERT(sizeof(Dest) == sizeof(Source), VerifySizesAreEqual);
|
| -
|
| + static_assert(sizeof(Dest) == sizeof(Source),
|
| + "source and dest must be same size");
|
| Dest dest;
|
| memcpy(&dest, &source, sizeof(dest));
|
| return dest;
|
|
|