public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC
@ 2022-05-23  7:59 roi.jacobson1 at gmail dot com
  2022-05-23 20:58 ` [Bug c++/105699] " roi.jacobson1 at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: roi.jacobson1 at gmail dot com @ 2022-05-23  7:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105699
           Summary: [Concepts] Constrained virtual functions are accepted
                    by GCC
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roi.jacobson1 at gmail dot com
  Target Milestone: ---

[class.virtual]p6 says virtual functions shall not be constrained. This example
from the standard is accepted in GCC:

template<typename T>
struct A {
  virtual void f() requires true; // Standard says is an error
};

Is this intentional?

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

* [Bug c++/105699] [Concepts] Constrained virtual functions are accepted by GCC
  2022-05-23  7:59 [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC roi.jacobson1 at gmail dot com
@ 2022-05-23 20:58 ` roi.jacobson1 at gmail dot com
  2022-05-24  7:46 ` fchelnokov at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: roi.jacobson1 at gmail dot com @ 2022-05-23 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Roy Jacobson <roi.jacobson1 at gmail dot com> ---
I want to suggest to also consider the case of overloading virtual functions
with non-virtual constrained functions. There's an open CWG issue about this
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2488 and the ABI
implications are very annoying. MSVC already forbid it.

It interacts very funnily with the special member functions paper (P0848).
Consider

template<int N>
struct A {
  A& operator=(A&&) requires true;
  virtual A& operator=(A&&);
};

template<int N>
struct B {
  B& operator=(B&&) requires false;
  virtual B& operator=(B&&);
};

template<int N>
struct C {
  ~C() requires true;
  virtual ~C();
};

template<int N>
struct D {
  ~D() requires false;
  virtual ~D();
};

template<int N>
struct E {
  void foo() requires false;
  virtual void foo();
};

template<int N>
struct F {
  void foo() requires false;
  virtual void foo();
};

Currently GCC will generate vtables for B,D, and for both E and F, which seems
wrong. (I think C shouldn't have a vtable but A probably should have one, if
I'm interpreting P0848 correctly).

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

* [Bug c++/105699] [Concepts] Constrained virtual functions are accepted by GCC
  2022-05-23  7:59 [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC roi.jacobson1 at gmail dot com
  2022-05-23 20:58 ` [Bug c++/105699] " roi.jacobson1 at gmail dot com
@ 2022-05-24  7:46 ` fchelnokov at gmail dot com
  2022-05-24  8:22 ` redi at gcc dot gnu.org
  2022-05-24  8:23 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fchelnokov at gmail dot com @ 2022-05-24  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
Another aspect is that the order of destructors in the class change its
behavior:

#include <type_traits>

template<int N>
struct X {
  ~X() requires (N==1);
  virtual ~X();
};

// X is NOT polymorphic in GCC
static_assert( !std::is_polymorphic_v<X<1>> );

template<int N>
struct Y {
  virtual ~Y();
  ~Y() requires (N==1);
};

// Y is polymorphic in GCC
static_assert( std::is_polymorphic_v<Y<1>> );

Demo: https://gcc.godbolt.org/z/493qr5K9d

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

* [Bug c++/105699] [Concepts] Constrained virtual functions are accepted by GCC
  2022-05-23  7:59 [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC roi.jacobson1 at gmail dot com
  2022-05-23 20:58 ` [Bug c++/105699] " roi.jacobson1 at gmail dot com
  2022-05-24  7:46 ` fchelnokov at gmail dot com
@ 2022-05-24  8:22 ` redi at gcc dot gnu.org
  2022-05-24  8:23 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-24  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |67491
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-05-24


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491
[Bug 67491] [meta-bug] concepts issues

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

* [Bug c++/105699] [Concepts] Constrained virtual functions are accepted by GCC
  2022-05-23  7:59 [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC roi.jacobson1 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-05-24  8:22 ` redi at gcc dot gnu.org
@ 2022-05-24  8:23 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-24  8:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|https://gcc.gnu.org/bugzill |
                   |a/show_bug.cgi?id=103865    |

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

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

end of thread, other threads:[~2022-05-24  8:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23  7:59 [Bug c++/105699] New: [Concepts] Constrained virtual functions are accepted by GCC roi.jacobson1 at gmail dot com
2022-05-23 20:58 ` [Bug c++/105699] " roi.jacobson1 at gmail dot com
2022-05-24  7:46 ` fchelnokov at gmail dot com
2022-05-24  8:22 ` redi at gcc dot gnu.org
2022-05-24  8:23 ` redi 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).