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

            Bug ID: 99664
           Summary: Overriding virtual function with different return type
                    (and not covariant) is allowed to compiled, when it
                    shouldn’t be
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ricardojvsilva10 at gmail dot com
  Target Milestone: ---

Test sammple code:

struct Res { };

struct A {
    virtual Res &&foo() &&;
};

struct B : A {
    Res &foo() && override; // allowed to compile by gcc, not by clang and MSVC 
};

In the previous test case, overriding virtual function A::foo with different
return type and not covariant from 'A::foo' is allowed and is succefully
compiled, when it shouldn’t be.


- Test sample: https://godbolt.org/z/1E98j9 


- Relevant standard entry [class.virtual] 11.7.3 - 7.1

https://timsong-cpp.github.io/cppwp/class.virtual#7.1

Reply via email to