[Bug c++/71653] New: error when trying to compile a code with template friend function in a struct

2016-06-24 Thread raphael.rg91 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71653

Bug ID: 71653
   Summary: error when trying to compile a code with template
friend function in a struct
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: raphael.rg91 at gmail dot com
  Target Milestone: ---

Created attachment 38764
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38764&action=edit
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 C f(T*)
 template  C 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
using C = typename std::conditional
>::value, typename std::add_const::type, typename
T::InnerType>::type [with T = S]’
 template  using C = typename
std::conditional::value, typename std::add_const::type, typename T::InnerType>::type;
   
   
  ^
testcase.cpp:3:166:   recursively required by substitution of ‘template using C = typename std::conditional
>::value, typename std::add_const::type, typename
T::InnerType>::type [with T = S]’
testcase.cpp:3:166:   required by substitution of ‘template using C =
typename std::conditional >::value,
typename std::add_const::type, typename
T::InnerType>::type [with T = S]’
testcase.cpp:5:28:   required by substitution of ‘template C f(T*)
[with T = S]’
testcase.cpp:16:9:   required from here

[Bug c++/71653] error when trying to compile a code with template friend function in a struct

2016-06-24 Thread raphael.rg91 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71653

--- Comment #1 from Raphael Gozzo  ---
Created attachment 38765
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38765&action=edit
source file

[Bug c++/71653] error when trying to compile a code with template friend function in a struct

2016-06-24 Thread raphael.rg91 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71653

--- Comment #2 from Raphael Gozzo  ---
This error happens in the 6.1 version too (tested here http://gcc.godbolt.org)