public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: carlo@alinoe.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/4379: Member pointer to member reference not allowed when declared directly, but allowed as template parameter.
Date: Sun, 23 Sep 2001 19:46:00 -0000	[thread overview]
Message-ID: <20010924024325.6757.qmail@sourceware.cygnus.com> (raw)

>Number:         4379
>Category:       c++
>Synopsis:       Member pointer to member reference not allowed when declared directly, but allowed as template parameter.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 23 19:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Carlo Wood
>Release:        3.x
>Organization:
>Environment:
i686-rawhide-gnu-linux
>Description:
g++ 3.x gives an error when declaring a function with
a parameter that is a member pointer to a reference
but allows to pass that as templated parameter at the
same time.

I believe it should be accepted always, but it certainly
is a bug because it is inconsistent.
>How-To-Repeat:
Compile the following code snippet.

// g++-3.1 -c bug.cc
 
typedef int a4_t[4];
typedef a4_t* ap4_t;
struct C {
  ap4_t c;
};
typedef int a3_t[3];
typedef a3_t& ar3_t;
a3_t a3 = { 1, 2, 3 };
struct D {
  D(void) : d(a3) { }
  ar3_t d;
};
 
template<class T4>
void f1(ap4_t (C::*), T4 x) { }         // T4 ends up as `ar3_t (D::*)'.
                                        // This allows to do:  D y; and use y.*x as a reference to y.d.
void test1(void)
{
  f1(&C::c, &D::d);                     // Works fine.
}
 
void f2(ap4_t (C::*), ar3_t (D::*)) { } // Wrong error: "cannot declare pointer to `int (&)[3]' member".
 
void test2(void)
{
  f2(&C::c, &D::d);                     // Doesn't work.
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-09-23 19:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-23 19:46 carlo [this message]
2001-09-23 19:56 Carlo Wood
2001-12-15 12:03 nathan
2002-01-02  3:39 nathan

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=20010924024325.6757.qmail@sourceware.cygnus.com \
    --to=carlo@alinoe.com \
    --cc=gcc-gnats@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).