diff options
author | Paul Groke <paul.groke@dynatrace.com> | 2022-09-15 13:36:49 +0200 |
---|---|---|
committer | Paul Groke <paul.groke@dynatrace.com> | 2022-09-15 13:36:49 +0200 |
commit | 096014a45dc38dff993f5b7bb28a258d8323344b (patch) | |
tree | 1ca88bb05b57855451a0ae32f674aa59013d8afa | |
parent | 9080381758fad853aa17ba1c3255ee8a35e452ca (diff) | |
download | googletest-git-096014a45dc38dff993f5b7bb28a258d8323344b.tar.gz |
work around GCC 6~11 ADL bug
see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51577
ADL seems to work properly when we do the SFINAE check via the return type, but not when using a dummy template parameter
fix #3992
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 8e4d2953..19c3e0b6 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -205,12 +205,13 @@ struct StreamPrinter { // Don't accept member pointers here. We'd print them via implicit // conversion to bool, which isn't useful. typename = typename std::enable_if< - !std::is_member_pointer<T>::value>::type, - // Only accept types for which we can find a streaming operator via - // ADL (possibly involving implicit conversions). - typename = decltype(std::declval<std::ostream&>() - << std::declval<const T&>())> - static void PrintValue(const T& value, ::std::ostream* os) { + !std::is_member_pointer<T>::value>::type> + // Only accept types for which we can find a streaming operator via + // ADL (possibly involving implicit conversions). + // (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name + // lookup properly when we do it in the template parameter list.) + static auto PrintValue(const T& value, ::std::ostream* os) + -> decltype((void)(*os << value)) { // Call streaming operator found by ADL, possibly with implicit conversions // of the arguments. *os << value; |