https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91911
Bug ID: 91911 Summary: Strange interaction between CTAD and decltype Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jeremy at jeremyms dot com Target Milestone: --- See example program below. Works in clang and MSVC. Fails in GCC 7.1 through trunk. #include <type_traits> #include <vector> #include <utility> template <typename T> struct span { using value_type = T; span(std::vector<T> &x) {} }; template <typename X> using SpanType = decltype(span(std::declval<X>())); // Compilation succeeds if we change line below to #if 1 #if 0 template <typename X> using ConstSpanType = span<const typename decltype(span(std::declval<X>()))::value_type>; #else template <typename X> using ConstSpanType = span<const typename SpanType<X>::value_type>; #endif static_assert( std::is_same_v<ConstSpanType<std::vector<int>&>, span<const int>>); Error: source>: In substitution of 'template<class X> using ConstSpanType = span<const typename decltype ((span<...auto...>)(declval<X>()))::value_type> [with X = std::vector<int>&]': <source>:25:51: required from here <source>:21:7: error: 'std::vector<int>&' is not a class, struct, or union type 21 | using ConstSpanType = span<const typename SpanType<X>::value_type>; | ^~~~~~~~~~~~~ <source>:25:10: error: template argument 1 is invalid 25 | std::is_same_v<ConstSpanType<std::vector<int>&>, span<const int>>); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compiler returned: 1 https://godbolt.org/z/ir4U26