Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3202)

Unified Diff: base/bit_cast.h

Issue 1925683002: Add simple bit_cast unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bit_cast.h, fix windows test compile Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | base/bit_cast_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bit_cast.h
diff --git a/base/bit_cast.h b/base/bit_cast.h
index 42d08ee8190a0a499ff0e5a5260d7802f9873fc0..c9514bceef4d861f660aa200eaccc997c6588361 100644
--- a/base/bit_cast.h
+++ b/base/bit_cast.h
@@ -65,9 +65,11 @@ inline Dest bit_cast(const Source& source) {
"bit_cast requires source and destination to be the same size");
#if (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) || \
- defined(_LIBCPP_VERSION))
+ (defined(__clang__) && defined(_LIBCPP_VERSION)))
// GCC 5.1 contains the first libstdc++ with is_trivially_copyable.
// Assume libc++ Just Works: is_trivially_copyable added on May 13th 2011.
+ // However, with libc++ when GCC is the compiler the trait is buggy, see
+ // crbug.com/607158, so fall back to the less strict variant for non-clang.
static_assert(std::is_trivially_copyable<Dest>::value,
"non-trivially-copyable bit_cast is undefined");
static_assert(std::is_trivially_copyable<Source>::value,
« no previous file with comments | « base/base.gyp ('k') | base/bit_cast_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698