From ca6a70c6082ff526b993c622d192c6d519800bc2 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 20 Jan 2017 12:54:07 -0500 Subject: [PATCH 1/2] Pass MSVC's C4826 warning. MSVC has an optional warning which flags when 32-bit pointers get cast into a 64-bit value. This is a little overaggressive I think, but to ease compiling in projects with aggressive warnings, fix this by just casting to const void * directly. Modern GCCs seem to compile it just fine. --- googletest/include/gtest/gtest-printers.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index e850d605..c6f69fa1 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -426,13 +426,8 @@ void DefaultPrintTo(WrapPrinterType /* dummy */, *os << "NULL"; } else { // T is a function type, so '*os << p' doesn't do what we want - // (it just prints p as bool). We want to print p as a const - // void*. However, we cannot cast it to const void* directly, - // even using reinterpret_cast, as earlier versions of gcc - // (e.g. 3.4.5) cannot compile the cast when p is a function - // pointer. Casting to UInt64 first solves the problem. - *os << reinterpret_cast( - reinterpret_cast(p)); + // (it just prints p as bool). Cast p to const void* to print it. + *os << reinterpret_cast(p); } } From 90244a6aef73d28b7d300c5b3e9d7c94bd6f437a Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 2 Jan 2018 12:55:44 -0500 Subject: [PATCH 2/2] Fix testing::Combine on MSVC 2017. On platforms with std::tuple and not std::tr1::tuple, GTEST_HAS_COMBINE gets turned off when it works fine (due to GTEST_TUPLE_NAMESPACE_). Elsewhere in the project, several GTEST_HAS_TR1_TUPLE checks additionally check GTEST_HAS_STD_TUPLE_, so use that formulation. (The ones that don't are specific to std::tr1::tuple and are followed by an identical GTEST_HAS_STD_TUPLE_ version underneath it.) In particular, this fixes testing::Combine on MSVC 2017, which regressed here: https://github.com/google/googletest/pull/1348#issuecomment-353879010 --- googletest/include/gtest/internal/gtest-port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 5d1b141d..8778bddd 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -827,7 +827,7 @@ using ::std::tuple_size; // Determines whether to support Combine(). // The implementation doesn't work on Sun Studio since it doesn't // understand templated conversion operators. -#if GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC) +#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC) # define GTEST_HAS_COMBINE 1 #endif