This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails
- From: "achovane at engin dot umich dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Aug 2004 20:52:04 -0000
- Subject: [Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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.
--
Summary: GCC fails to eliminate function template specialization
when argument deduction fails
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: achovane at engin dot umich dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17132