From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-id: <20010924024325.6757.qmail@sourceware.cygnus.com> X-SW-Source: 2001-09/msg00466.html List-Id: >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 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: