https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114620

            Bug ID: 114620
           Summary: Pointer-to-member template argument which is the
                    member of a base class is rejected
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mital at mitalashok dot co.uk
  Target Milestone: ---

The following is incorrectly rejected:

    struct Base {
        int x;
    };
    struct Derived : Base {
        int y;
    };
    template<int Derived::*> struct X;

    // error: '&Base::x' is not a valid template argument for type 'int
Derived::*'
    using T1 = X<&Derived::x>;
    //           ^~~~~~~~~~~
    // note: because it is a member of 'Base'

    constexpr int Derived::* pm = &Derived::x;
    // error: '0' is not a valid template argument for type 'int Derived::*'
    using T2 = X<pm>;
    //             ^
    // note: it must be a pointer-to-member of the form '&X::Y'

And replacing `&Derived::x` with `&Derived::y` works. The same problems happen
with pointer-to-member-functions instead of pointers to data members.

This seems similar to Bug 104678

Reply via email to