This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/4379: Member pointer to member reference not allowed when declared directly, but allowed as template parameter.



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]