public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jason at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/10126] ICE in convert_nontype_argument on using overload resolution in template args
Date: Tue, 02 Dec 2003 05:51:00 -0000	[thread overview]
Message-ID: <20031202055123.634.qmail@sources.redhat.com> (raw)
In-Reply-To: <20030318001600.10126.marco.franzen@bigfoot.com>


------- Additional Comments From jason at gcc dot gnu dot org  2003-12-02 05:51 -------
This testcase is ill-formed:

  5.3.1  Unary operators                                 [expr.unary.op]

2 The result of the unary & operator is a pointer to its  operand.   The
  operand  shall  be an lvalue or a qualified-id....  
                                                   For  a  qualified-id,
  if  the  member is a static member of type "T", the type of the result
  is plain "pointer to T."  If the member is a nonstatic member of class
  C  of  type T, the type of the result is "pointer to member of class C
  of type T."  [Example:

     struct A { int i; };
     struct B : A { };
     ... &B::i ...                 // has type int A::*

   --end example]

  14.3.2  Template non-type arguments                 [temp.arg.nontype]
  
  --  For  a  non-type  template-parameter  of  type  pointer  to member
      function,  no  conversions  apply.    If   the   template-argument
      represents  a  set  of  overloaded  member functions, the matching
      member function is selected from the set (_over.over_).

For better or worse, in this case worse, &Strawberry::I has type pointer to
member function of Fruit, not of Strawberry, and no conversion is done to make
it a pointer to member function of Strawberry.  To make it work, you need to add
an explicit downcast:

  dish.Get<(int const& (Strawberry::*fun)() const)&Strawberry::I>();

Dave, your testcase in 13040 is similarly ill-formed.

I'm not arguing that these rules make sense, but that is in fact what they say.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10126


  parent reply	other threads:[~2003-12-02  5:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030318001600.10126.marco.franzen@bigfoot.com>
2003-06-07 16:40 ` pinskia@physics.uc.edu
2003-07-14 15:02 ` pinskia at physics dot uc dot edu
2003-11-13 16:16 ` bangerth at dealii dot org
2003-11-19 10:02 ` giovannibajo at libero dot it
2003-11-20  7:05 ` pinskia at gcc dot gnu dot org
2003-11-20  7:05 ` pinskia at gcc dot gnu dot org
2003-12-02  5:51 ` jason at gcc dot gnu dot org [this message]
2003-12-02 15:46 ` cvs-commit at gcc dot gnu dot org
2003-12-02 15:50 ` cvs-commit at gcc dot gnu dot org
2003-12-02 15:53 ` giovannibajo at libero dot it
2003-12-09 17:58 ` dhazeghi at yahoo dot com
2003-12-11 21:56 ` marco dot franzen at bigfoot dot com
2003-12-12  8:50 ` bangerth at dealii 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=20031202055123.634.qmail@sources.redhat.com \
    --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).