From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 244FA3858D20; Wed, 23 Feb 2022 07:25:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 244FA3858D20 From: "lichray at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104653] New: Derived class looks for a definition of its inherited constexpr virtual destructor Date: Wed, 23 Feb 2022 07:25:02 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lichray at gmail dot com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2022 07:25:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104653 Bug ID: 104653 Summary: Derived class looks for a definition of its inherited constexpr virtual destructor Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lichray at gmail dot com Target Milestone: --- The following -std=3Dc++20 code fails to compile: #include struct B { virtual ~B() =3D default; }; struct D : B {}; struct C : B {}; bool foo(std::byte *p) { constexpr D obj; return __builtin_memcmp(p, &obj, sizeof(void *)) =3D=3D 0; } : In function 'bool foo(std::byte*)': :12:17: error: 'virtual constexpr D::~D()' used before its definiti= on 12 | constexpr D obj; | ^~~ The code compiles in MSVC 19.29 and Clang 10. GCC seems to understand that D inherited a defaulted, constexpr virtual destructor, but reports that it needs a definition. The problem doesn't ari= se if D is dependent. A workaround is the following: struct D : B { virtual constexpr ~D() override; }; constexpr D::~D() =3D default;=