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

            Bug ID: 128456
           Summary: using-declaration skips access check when the member
                    is also reachable via another public path
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

```
struct A { static int x; };
class B : A {};
struct C : A {};

struct D : B, C {
    using B::x; // must be rejected, GCC accepts
    using B::A; // same for the injected-class-name
};
```

The naming class of `B::x` and `B::A` is B ([class.access.base]/5), where both
are private, so the using-declarations in D are ill-formed
([namespace.udecl]/19). The public path through C must not matter (without C,
GCC rejects them). Clang and EDG reject both:
https://gcc.godbolt.org/z/91doaq6Wo

Related: https://stackoverflow.com/q/69311086/7325599

Reply via email to