https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100592
Bug ID: 100592 Summary: Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- template<bool> struct meta { template<class T, class U> using if_c = T; }; template<> struct meta<false> { template<class T, class U> using if_c = U; }; template <bool B, class T, class U> using if_c = typename meta<B>::template if_c<T, U>; template<class> inline constexpr bool b = false; template <class T> using foo = if_c<b<T>, int, T>; template<class T> struct type {}; template <typename T> using test = type<foo<T> const&>; template<class T> test<T> f(); void g() { f<int&>(); } GCC rejects: <source>: In function 'void g()': <source>:32:12: error: no matching function for call to 'f<int&>()' 32 | f<int&>(); | ~~~~~~~^~ <source>:29:9: note: candidate: 'template<class T> test<T> f()' 29 | test<T> f(); | ^ <source>:29:9: note: template argument deduction/substitution failed: <source>: In substitution of 'template<class T> using test = type<const typename meta<b<T> >::if_c<int, T>&> [with T = int&]': <source>:29:9: required by substitution of 'template<class T> test<T> f() [with T = int&]' <source>:32:12: required from here <source>:26:7: error: 'const' qualifiers cannot be applied to 'meta<false>::if_c<int, int&>' {aka 'int&'} 26 | using test = type<foo<T> const&>; | ^~~~