public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "achovane at engin dot umich dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/17132] New: GCC fails to eliminate function template specialization when argument deduction fails
Date: Sat, 21 Aug 2004 20:52:00 -0000	[thread overview]
Message-ID: <20040821205203.17132.achovane@engin.umich.edu> (raw)

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


             reply	other threads:[~2004-08-21 20:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-21 20:52 achovane at engin dot umich dot edu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040821205203.17132.achovane@engin.umich.edu \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).