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

            Bug ID: 102423
           Summary: False accept of virtual methods with deduced return
                    type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

GCC erroneously accepts virtual methods with deduced return type, which are
prohibited by the standard (https://eel.is/c++draft/dcl.spec.auto#general-14):
```
#include <iostream>

struct A {
    virtual auto f() -> auto { return 1; }
};

struct B: A {
    virtual auto f() -> auto override { return 2.5; }
};

int main() {
    B b;
    A & a = b;
    std::cout << b.A::f() << ' ' << b.f() << ' ' << a.f();
}
```
Demo: https://gcc.godbolt.org/z/n3ejPshe7

Reply via email to