public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99664] New: Overriding virtual function with different return type (and not covariant) is allowed to compiled, when it shouldn’t be
@ 2021-03-19  9:44 ricardojvsilva10 at gmail dot com
  2021-03-19  9:51 ` [Bug c++/99664] " ricardojvsilva10 at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ricardojvsilva10 at gmail dot com @ 2021-03-19  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-16 20:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19  9:44 [Bug c++/99664] New: Overriding virtual function with different return type (and not covariant) is allowed to compiled, when it shouldn’t be ricardojvsilva10 at gmail dot com
2021-03-19  9:51 ` [Bug c++/99664] " ricardojvsilva10 at gmail dot com
2021-03-19 10:17 ` redi at gcc dot gnu.org
2021-07-15 12:38 ` [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compile, " redi at gcc dot gnu.org
2021-07-15 14:51 ` ppalka at gcc dot gnu.org
2021-07-16 20:21 ` cvs-commit at gcc dot gnu.org
2021-07-16 20:23 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).