From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14581 invoked by alias); 21 Aug 2004 20:52:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14573 invoked by uid 48); 21 Aug 2004 20:52:04 -0000 Date: Sat, 21 Aug 2004 20:52:00 -0000 From: "achovane at engin dot umich dot edu" To: gcc-bugs@gcc.gnu.org Message-ID: <20040821205203.17132.achovane@engin.umich.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg02183.txt.bz2 List-Id: 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 *' 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