From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 77D153858D3C; Tue, 28 Feb 2023 10:34:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77D153858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677580476; bh=3+jpW+r964laPi5Q4fWzDsXQaWtpQ6mDfFoBw1SQnYk=; h=From:To:Subject:Date:From; b=l+cqZZzywoFuvo5xX1YAqZiMsSje/kD3AFqouMRzkoARog/Hbo/H32D/stZ0PJitu jk4VdvlO5SD91PVyq3XBDJjfivYStmgESnj8mJE6Y3q0Ip/HTK5+i1qmahsPBdTl3r m/e0GETV86HfPEZzHCWo9UqdAGNS5ss8Igh0oKOY= From: "gcc@arne-mertz.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108966] New: Inheriting consteval constructor makes it constexpr in the derived class Date: Tue, 28 Feb 2023 10:34:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc@arne-mertz.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108966 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=20 ``` : In constructor 'constexpr T::T(double&&) [inherited from X]': :8:14: error: 'this' is not a constant expression 8 | using X::X; ``` This indicates that the inherited constructor is considered `constexpr` ins= tead of `consteval` and is therefore unable to call the `consteval` base class constructor. See it in action: https://godbolt.org/z/K6T6f1691 Note:=20 - this does not happen when the constructor is replaced with `X::X() =3D de= fault` and no initializer is given to `t`, but a similar error appears with `X::X() {}`=