When compiling test_no_amperspand.cpp, GCC generates the following error: "error: `operator*' is not a member of type `empty'" GCC attempts to instantiate a specialization of the function template 'test' which accepts a parameter of type `func_tag<Type, Type::operator*> *' with a default value of 0. Since type 'empty' is a struct which does not overload `operator*', this specialization should not be included in the set of candidate functions for the call to `test' on line 19, according to the SFINAE (substitution-failure-is-not an-error) principle. The C++ Standard states: "... For each function template, if the argument deduction and checking succeeds, the template-arguments (deduced and/or explicit) are used to instantiate a single function template specialization which is added to the candidate functions set to be used in overload resolution. If, for a given function template, argument deduction fails, no such function is added to the set of candidate functions for that template." Since a non-template function `test' is defined which accepts a parameter of type `void *', the call on 19 is satisfied. Thus, this program is correct and should compile. The second file, test_amperspand.cpp, is identical to the first, except that on line 14, `Type::operator*' is replaced with `&Type::operator*'. (Both forms are correct.) In the latter case (test_amperspand.cpp), GCC generates the following error: "internal compiler error: Segmentation fault" Both of these programs compile without error under Intel C++ 8.0 and Comeau C/C++ 4.3.0.
Created attachment 6971 [details] first version of source file
Created attachment 6972 [details] compiler output for first version of source file
Created attachment 6973 [details] second version of source file
Created attachment 6974 [details] compiler output for second version of source file
The first one now ICE in 3.4.0 so that is a regression. Confirmed.
I am posting a third source file along with the output that GCC generates when I try to compile it. Here, has_deref is instantiated with a type that defines `operator*', so argument deduction should succeed, and the appropriate specialization of the `test' function template should be called, because `Type *' is a better match than `void *'. However, in this case GCC generates a different internal compiler error: "internal compiler error: in mangle_class_name_for_template, at cp/pt.c:3848"
Created attachment 6975 [details] third version of source file
Created attachment 6976 [details] compiler output for third version of source file
: Search converges between 2003-07-07-trunk (#287) and 2003-07-08-trunk (#288).
Postponed until GCC 3.4.3.
Subject: Bug 17132 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-10-28 20:53:04 Modified files: gcc/cp : ChangeLog pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: memclass3.C Log message: PR c++/17132 * pt.c (instantiate_class_template): Increment processing_template_decl when substituting into a member class template. PR c++/17132 * g++.dg/template/memclass3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4460&r2=1.4461 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.938&r2=1.939 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4513&r2=1.4514 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memclass3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 17132 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-10-28 20:56:55 Modified files: gcc/cp : ChangeLog pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: memclass3.C Log message: PR c++/17132 * pt.c (instantiate_class_template): Increment processing_template_decl when substituting into a member class template. PR c++/17132 * g++.dg/template/memclass3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.175&r2=1.3892.2.176 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.44&r2=1.816.2.45 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.299&r2=1.3389.2.300 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memclass3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.3.