public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails
@ 2004-08-21 20:52 achovane at engin dot umich dot edu
  2004-08-21 20:53 ` [Bug c++/17132] " achovane at engin dot umich dot edu
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: achovane at engin dot umich dot edu @ 2004-08-21 20:52 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-10-28 21:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-21 20:52 [Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails achovane at engin dot umich dot edu
2004-08-21 20:53 ` [Bug c++/17132] " achovane at engin dot umich dot edu
2004-08-21 20:54 ` achovane at engin dot umich dot edu
2004-08-21 20:55 ` achovane at engin dot umich dot edu
2004-08-21 20:55 ` achovane at engin dot umich dot edu
2004-08-21 21:06 ` [Bug c++/17132] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-21 22:25 ` achovane at engin dot umich dot edu
2004-08-22 17:25 ` pinskia at gcc dot gnu dot org
2004-08-29 18:12 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:16 ` mmitchel at gcc dot gnu dot org
2004-10-28 17:32 ` [Bug c++/17132] [3.4/4.0 " mmitchel at gcc dot gnu dot org
2004-10-28 20:53 ` cvs-commit at gcc dot gnu dot org
2004-10-28 20:56 ` cvs-commit at gcc dot gnu dot org
2004-10-28 21:01 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).