public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108966] New: Inheriting consteval constructor makes it constexpr in the derived class
@ 2023-02-28 10:34 gcc@arne-mertz.de
2023-02-28 17:10 ` [Bug c++/108966] " ppalka at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: gcc@arne-mertz.de @ 2023-02-28 10:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108966
Bug ID: 108966
Summary: Inheriting consteval constructor makes it constexpr in
the derived class
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc@arne-mertz.de
Target Milestone: ---
Consider the following code:
```
struct X
{
consteval X(int) {};
};
struct T : X
{
using X::X;
};
constexpr T t(22);
```
The using directive (1) should lead to a `consteval T::T(int)`. However, the
compiler errors with message
```
<source>: In constructor 'constexpr T::T(double&&) [inherited from X]':
<source>:8:14: error: 'this' is not a constant expression
8 | using X::X;
```
This indicates that the inherited constructor is considered `constexpr` instead
of `consteval` and is therefore unable to call the `consteval` base class
constructor.
See it in action: https://godbolt.org/z/K6T6f1691
Note:
- this does not happen when the constructor is replaced with `X::X() = default`
and no initializer is given to `t`, but a similar error appears with `X::X()
{}`
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/108966] Inheriting consteval constructor makes it constexpr in the derived class
2023-02-28 10:34 [Bug c++/108966] New: Inheriting consteval constructor makes it constexpr in the derived class gcc@arne-mertz.de
@ 2023-02-28 17:10 ` ppalka at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-02-28 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108966
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
CC| |ppalka at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
dup
*** This bug has been marked as a duplicate of bug 104490 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-28 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 10:34 [Bug c++/108966] New: Inheriting consteval constructor makes it constexpr in the derived class gcc@arne-mertz.de
2023-02-28 17:10 ` [Bug c++/108966] " 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).