From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E6D673858D1E; Thu, 8 Sep 2022 10:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6D673858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662631619; bh=+4qd1G07MqtVYOKwG6Z5VZncf20BhaYG6TEj7NRdf6w=; h=From:To:Subject:Date:From; b=XOaC4boHONqEKj4pILXzXT9xpMrniFf/RMchQ58HJZFYk8aBZP56Ad8hH8nAsV0pP XYCEv3eLEjk8cDA55M+UiDrszcEkpapjlnj7bCGCtuGFhi6IL/X73w5nF+ko5VaeYn Vn3PYygrEwFy5faDGCEt7IzFGA0vYDO3yq8FI0L8= From: "thomas at thomaslabs dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106890] New: virtual inheritance triggers compiler error when instatiating derived class with in-class initialization Date: Thu, 08 Sep 2022 10:06:59 +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: thomas at thomaslabs dot org 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 attachments.created 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=3D106890 Bug ID: 106890 Summary: virtual inheritance triggers compiler error when instatiating derived class with in-class initialization Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thomas at thomaslabs dot org Target Milestone: --- Created attachment 53549 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53549&action=3Dedit The exact source code used to trigger the error The following code sample triggers an internal compiler error. This happends when using the virtual keyword in the definition of B and is related to the function call to f inside the class definition. When later attempting to instantiate the class B the compiler fails. I'm working with GCC version 12.2.0 but this bug seems to be present as ear= ly as version 8.5.0. Version 7.5.0 managed to compile without a problem. * Command line=20 g++ bug.cpp * Compiler output: during RTL pass: expand bug.cpp: In constructor =E2=80=98B::B(int) [with T =3D int]=E2=80=99: bug.cpp:26:5: internal compiler error: in expand_expr_real_1, at expr.cc:10= 586 26 | B(int a) { | ^ 0x1b286a6 internal_error(char const*, ...) ???:0 0x6ccc1e fancy_abort(char const*, int, char const*) ???:0 * Compiler version: GNU C++17 (GCC) version 12.2.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP * System GNU/Guix x86_64 * Source code class O { public: int f() { return 1; } }; template class A { public: A(); A(int a); protected: O p =3D O(); }; template class B : virtual public A { public: B() { } B(int a) { } protected: using A::p; unsigned int k =3D p.f(); }; template class B; int main() { return 0; }=