Created attachment 38764 [details] preprocessed file $ g++ -v -save-temps -std=c++11 -c testcase.cpp Using built-in specs. COLLECT_GCC=g++ Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-4.8 --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux Thread model: posix gcc version 4.8.5 (SUSE Linux) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib64/gcc/x86_64-suse-linux/4.8/cc1plus -E -quiet -v -D_GNU_SOURCE testcase.cpp -mtune=generic -march=x86-64 -std=c++11 -fpch-preprocess -o testcase.ii #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.8 /usr/include/c++/4.8/x86_64-suse-linux /usr/include/c++/4.8/backward /usr/lib64/gcc/x86_64-suse-linux/4.8/include /usr/local/include /usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib64/gcc/x86_64-suse-linux/4.8/cc1plus -fpreprocessed testcase.ii -quiet -dumpbase testcase.cpp -mtune=generic -march=x86-64 -auxbase testcase -std=c++11 -version -o testcase.s GNU C++ (SUSE Linux) version 4.8.5 (x86_64-suse-linux) compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++ (SUSE Linux) version 4.8.5 (x86_64-suse-linux) compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: ca63ef29755a145e45a587295d513e14 testcase.cpp: In function ‘int main()’: testcase.cpp:16:9: error: no matching function for call to ‘f(S*)’ f(&s); ^ testcase.cpp:16:9: note: candidate is: testcase.cpp:5:28: note: template<class T> C<T> f(T*) template <typename T> C<T> f(T *); ^ testcase.cpp:5:28: note: template argument deduction/substitution failed: testcase.cpp:3:166: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) substituting ‘template<class T> using C = typename std::conditional<std::is_const< <template-parameter-1-1> >::value, typename std::add_const<typename T::InnerType>::type, typename T::InnerType>::type [with T = S]’ template <typename T> using C = typename std::conditional<std::is_const<T>::value, typename std::add_const<typename T::InnerType>::type, typename T::InnerType>::type; ^ testcase.cpp:3:166: recursively required by substitution of ‘template<class T> using C = typename std::conditional<std::is_const< <template-parameter-1-1> >::value, typename std::add_const<typename T::InnerType>::type, typename T::InnerType>::type [with T = S]’ testcase.cpp:3:166: required by substitution of ‘template<class T> using C = typename std::conditional<std::is_const< <template-parameter-1-1> >::value, typename std::add_const<typename T::InnerType>::type, typename T::InnerType>::type [with T = S]’ testcase.cpp:5:28: required by substitution of ‘template<class T> C<T> f(T*) [with T = S]’ testcase.cpp:16:9: required from here
Created attachment 38765 [details] source file
This error happens in the 6.1 version too (tested here http://gcc.godbolt.org)
Reduced testcase without includes: template <typename T> using C = typename T::InnerType; template <typename T> C<T> f(T &); class S { using InnerType = int; template <typename T> friend C<T> f(T &); }; int main() { S s; f(s); return 0; }
If I don't use an alias template in the original declaration of f it works: template <typename T> using C = typename T::InnerType; template <typename T> typename T::InnerType f(T &); class S { using InnerType = int; template <typename T> friend C<T> f(T &); }; int main() { S s; f(s); return 0; }