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: g...@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()
{}`

Reply via email to