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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compiled, when it shouldn’t be
  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 ` ricardojvsilva10 at gmail dot com
  2021-03-19 10:17 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ricardojvsilva10 at gmail dot com @ 2021-03-19  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Ricardo Silva <ricardojvsilva10 at gmail dot com> ---
>From here https://stackoverflow.com/q/66698168/6865932

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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compiled, when it shouldn’t be
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-19 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-03-19
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. Not a regression.

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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compile, when it shouldn’t be
  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 ` redi at gcc dot gnu.org
  2021-07-15 14:51 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-15 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xmh970252187 at gmail dot com

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 101458 has been marked as a duplicate of this bug. ***

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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compile, when it shouldn’t be
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-15 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compile, when it shouldn’t be
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-16 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:d04b0c75794545f1f7a942764285e21eaf2915a1

commit r12-2377-gd04b0c75794545f1f7a942764285e21eaf2915a1
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 16 16:21:10 2021 -0400

    c++: covariant reference return types [PR99664]

    This implements the wording changes of CWG 960 which clarifies that two
    reference types are covariant only if they're both lvalue references
    or both rvalue references.

            DR 960
            PR c++/99664

    gcc/cp/ChangeLog:

            * search.c (check_final_overrider): Compare TYPE_REF_IS_RVALUE
            when the return types are references.

    gcc/testsuite/ChangeLog:

            * g++.dg/inherit/covariant23.C: New test.

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

* [Bug c++/99664] Overriding virtual function with different return type (and not covariant) is allowed to compile, when it shouldn’t be
  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
                   ` (4 preceding siblings ...)
  2021-07-16 20:21 ` cvs-commit at gcc dot gnu.org
@ 2021-07-16 20:23 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-16 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

^ 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).