From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D1ED93861803; Tue, 16 Jan 2024 15:07:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1ED93861803 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705417627; bh=q4VrsALf8yuQUNUMgTkQJy4go0TFpMYb5iWCiaZKuz0=; h=From:To:Subject:Date:From; b=nkQDkyCvmNvsSCGSrNjKlPIE+XPArVu3c7ZiNA49zixhqi2wMJhx+9oXRHW9ZSg/g 9X8g6g7RwQpKQuV2Mo/ey+yv/Fgh4cm5NQfEJmqGSAce0z0PYd4MALC3kEBHo4qP/O lPyYrsRYBtei0gx+fXadUaVINiMc0zGfq8L9QzH8= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113427] New: ICE: tree check: C++23 `this auto` lambda + multiple (ambiguous) inheritance from closure type Date: Tue, 16 Jan 2024 15:07:07 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arthur.j.odwyer 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113427 Bug ID: 113427 Summary: ICE: tree check: C++23 `this auto` lambda + multiple (ambiguous) inheritance from closure type Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arthur.j.odwyer at gmail dot com Target Milestone: --- // https://godbolt.org/z/fd3zzfrTd auto factory(int x) { return [x=3Dx](this auto self) { return x; }; } using Lambda =3D decltype(factory(0)); struct LeftCat : Lambda { LeftCat() : Lambda(factory(1)) {} }; struct RightCat : Lambda { RightCat() : Lambda(factory(2)) {} }; struct SiameseCat : LeftCat, RightCat { using Lambda::operator(); }; int main() { return SiameseCat()(); } =3D=3D=3D : In instantiation of 'factory(int):: [with au= to:1 =3D SiameseCat]': :11:24: required from here 11 | return SiameseCat()(); | ~~~~~~~~~~~~^~ :3:32: error: 'factory(int)::' is an ambiguous base of 'SiameseCat' 3 | return [x=3Dx](this auto self) { return x; }; | ^ :3:32: error: 'factory(int)::' is an ambiguous base of 'SiameseCat' :3:32: internal compiler error: tree check: expected class 'type', = have 'exceptional' (error_mark) in tsubst_decl, at cp/pt.cc:15542 0x264113c internal_error(char const*, ...) ???:0 0x9641cf tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ???:0 0xa88c8c tree_class_check(tree_node*, tree_code_class, char const*, int, ch= ar const*) ???:0 0xc88d63 instantiate_decl(tree_node*, bool, bool) ???:0 0xb4de55 maybe_instantiate_decl(tree_node*) ???:0 0xb4f948 mark_used(tree_node*, int) ???:0 0xa81a04 build_op_call(tree_node*, vec**, int) ???:0 0xcce9e7 finish_call_expr(tree_node*, vec**, b= ool, bool, int) ???:0 0xc521ea c_parse_file() ???:0 0xda5b99 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. =3D=3D=3D Found by noodling around with explicit object parameters and corner cases related to https://eel.is/c++draft/expr.prim.lambda#closure-5 . That wording currently demands that the explicit object parameter of a capturing lambda = be "a class type derived from the closure type," but it probably ought to say = more like "a class type _unambiguously_ derived from the closure type." At least= , I don't know what the expected behavior of the above program ought to be, if = it's _not_ supposed to be ill-formed. I think GCC's ICE happens because GCC is trying too hard to assign a meaning to an essentially meaningless program.=