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

            Bug ID: 116636
           Summary: Deprecation warning/unavailable error when overriding
                    member of virtual base class
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

Repro:

struct B {
    virtual void f() = 0;
};
struct C : virtual B {
    [[deprecated("meow")]]
    void f() override {}
};

<source>:6:24: warning: 'virtual void C::f()' is deprecated: meow
[-Wdeprecated-declarations]
    6 |     void f() override {}
      |                        ^
<source>:6:10: note: declared here
    6 |     void f() override {}
      |          ^

Likewise:

struct B {
    virtual void f() = 0;
};
struct C : virtual B {
    [[gnu::unavailable("meow")]]
    void f() override {}
};

<source>:6:24: error: 'virtual void C::f()' is unavailable: meow
    6 |     void f() override {}
      |                        ^
<source>:6:10: note: declared here
    6 |     void f() override {}
      |          ^


Making the base class non-virtual makes the warning/error go away.

Reply via email to