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

            Bug ID: 104488
           Summary: Wrong access specification in method pointer
                    assignment
           Product: gcc
           Version: og11 (devel/omp/gcc-11)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at elchris dot org
  Target Milestone: ---

Created attachment 52405
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52405&action=edit
someFunc is made public by using but the method ptr assignment does not
recognize it

## Source Code
```
// file: blubb.cpp
template <typename T>
class Parent {
 protected:
  template <typename R = T>
  void someFunc() {}
};

class Child : public Parent<int> {
 public:
  using Parent::someFunc;
};

int main() { void (Child::*methodPtr)() = &Child::someFunc; }
```

## Compilation command
```
g++ blubb.cpp
```

## Error
```
blubb.cpp: In function ‘int main()’:
blubb.cpp:13:51: error: ‘void Parent<T>::someFunc() [with R = int; T = int]’ is
protected within this context
   13 | int main() { void (Child::*methodPtr)() = &Child::someFunc; }
      |                                                   ^~~~~~~~
blubb.cpp:5:8: note: declared protected here
    5 |   void someFunc() {}
      |        ^~~~~~~~
```

## Compiler Version

```
gcc --version

gcc (GCC) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```


## System

```
uname -a

Linux 5.16.8-arch1-1 #1 SMP PREEMPT Tue, 08 Feb 2022 21:21:08 +0000 x86_64
GNU/Linux
```

Reply via email to