diff options
author | drgler <daniel.kruegler@gmail.com> | 2017-08-09 17:07:22 (GMT) |
---|---|---|
committer | drgler <daniel.kruegler@gmail.com> | 2017-08-09 17:08:22 (GMT) |
commit | 71ca4bae1085d7f2adefcbd16b0b7cebb81d540f (patch) | |
tree | 1214077ca2650150333566239feaf4c2aa6749c3 /googletest/include/gtest/gtest-printers.h | |
parent | 4bab34d2084259cba67f3bfb51217c10d606e175 (diff) | |
download | googletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.zip googletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.tar.gz googletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.tar.bz2 |
Infinite Loop when calling a mock function that takes boost::filesystem::path as parameter #521: Add is_same type trait and prevent infinite loops for recursive containers
Diffstat (limited to 'googletest/include/gtest/gtest-printers.h')
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index e850d60..fba7661 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -460,15 +460,17 @@ void PrintTo(const T& value, ::std::ostream* os) { // DefaultPrintTo() is overloaded. The type of its first argument // determines which version will be picked. // - // Note that we check for container types here, prior to we check - // for protocol message types in our operator<<. The rationale is: + // Note that we check for recursive and other container types here, prior + // to we check for protocol message types in our operator<<. The rationale is: // // For protocol messages, we want to give people a chance to // override Google Mock's format by defining a PrintTo() or // operator<<. For STL containers, other formats can be // incompatible with Google Mock's format for the container // elements; therefore we check for container types here to ensure - // that our format is used. + // that our format is used. To prevent an infinite runtime recursion + // during the output of recursive container types, we check first for + // those. // // Note that MSVC and clang-cl do allow an implicit conversion from // pointer-to-function to pointer-to-object, but clang-cl warns on it. @@ -477,16 +479,17 @@ void PrintTo(const T& value, ::std::ostream* os) { // function pointers so that the `*os << p` in the object pointer overload // doesn't cause that warning either. DefaultPrintTo( - WrapPrinterType<sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer) - ? kPrintContainer : !is_pointer<T>::value - ? kPrintOther + WrapPrinterType< + (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) && !IsRecursiveContainer<T>::value + ? kPrintContainer : !is_pointer<T>::value + ? kPrintOther #if GTEST_LANG_CXX11 : std::is_function<typename std::remove_pointer<T>::type>::value #else : !internal::ImplicitlyConvertible<T, const void*>::value #endif - ? kPrintFunctionPointer - : kPrintPointer>(), + ? kPrintFunctionPointer + : kPrintPointer>(), value, os); } |