@@ -261,16 +261,23 @@ struct ConvertibleToStringViewPrinter {
261261GTEST_API_ void PrintBytesInObjectTo (const unsigned char * obj_bytes,
262262 size_t count,
263263 ::std::ostream* os);
264- struct FallbackPrinter {
265- template <typename T>
264+ struct RawBytesPrinter {
265+ // SFINAE on `sizeof` to make sure we have a complete type.
266+ template <typename T, size_t = sizeof (T)>
266267 static void PrintValue (const T& value, ::std::ostream* os) {
267268 PrintBytesInObjectTo (
268- static_cast <const unsigned char *>(
269- reinterpret_cast <const void *>(std::addressof (value))),
269+ reinterpret_cast <const unsigned char *>(std::addressof (value)),
270270 sizeof (value), os);
271271 }
272272};
273273
274+ struct FallbackPrinter {
275+ template <typename T>
276+ static void PrintValue (const T&, ::std::ostream* os) {
277+ *os << " (incomplete type)" ;
278+ }
279+ };
280+
274281// Try every printer in order and return the first one that works.
275282template <typename T, typename E, typename Printer, typename ... Printers>
276283struct FindFirstPrinter : FindFirstPrinter<T, E, Printers...> {};
@@ -297,7 +304,7 @@ void PrintWithFallback(const T& value, ::std::ostream* os) {
297304 T, void , ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
298305 internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
299306 ProtobufPrinter, ConvertibleToIntegerPrinter,
300- ConvertibleToStringViewPrinter, FallbackPrinter>::type;
307+ ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;
301308 Printer::PrintValue (value, os);
302309}
303310
0 commit comments