From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B47043858C53; Tue, 6 Feb 2024 17:51:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B47043858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707241885; bh=ekfhuJoL8lA4+KF4ziWsfDBpPWr4irW3QiNA1BBSsGk=; h=From:To:Subject:Date:From; b=G6chRrCJyxa44WLJmWpVe9wFEC/Dd2K7gw2P0abeibkwBv731gZDaN43iCEudbmGH ZN4kKj4h6JwPyO6U6Mv2/E1opbu6vJfasp6HD03K6gpanSKS6zv7+jvXh5S6bjf3E4 FNepmbcfON3DpeUVKmilfPLRTDnLnbQX7j+Abo0Q= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113789] New: ICE on P2266/C++23 `decltype(throw x)` where x is move-eligible parameter Date: Tue, 06 Feb 2024 17:51:25 +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: 14.0 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=3D113789 Bug ID: 113789 Summary: ICE on P2266/C++23 `decltype(throw x)` where x is move-eligible parameter Product: gcc Version: 14.0 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: --- P2266 "Simpler Implicit Move", adopted for C++23, intends that a move-eligi= ble `x` should be treated as an xvalue in the context of `throw x`. This means = that `throw x` should be ill-formed (SFINAE-friendly) when `x` isn't move-constructible. (This might be complicated by the GCC+Clang extension that permits move-only types to be thrown even though the paper Standard technically prohibits tha= t.) That is, the test program in this blog post is expected to pass after P2266: https://quuxplusone.github.io/blog/2021/03/18/sfinae-on-throw-x/#here-is-a-= program-that-uses-sfin Clang passes; GCC fails; MSVC and EDG don't seem to implement P2266 `throw` yet. But the real problem for GCC is that if you then use `throw x` inside the function body after using `decltype(throw x)` in the function's return type, the compiler ICEs! // https://godbolt.org/z/YG16hE7zT struct AutoPtr { AutoPtr() =3D default; AutoPtr(AutoPtr&) {} }; template auto f(T p, int) -> decltype(throw p, 1) { throw p; } template int f(T p, long) { return 2; } int main() { return f(AutoPtr(), 42); } The expected behavior (and Clang's behavior) is to call `f(T, long)`. GCC 12 generates a call to `f(T, int)`. GCC 13 crashes with this output (including that leading single-quote): ' internal compiler error: error reporting routines re-entered. 0x2648345 diagnostic_context::report_diagnostic(diagnostic_info*) ???:0 0x26494c5 error_at(unsigned int, char const*, ...) ???:0 0xa7d834 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int) ???:0 0xa7eb5b build_special_member_call(tree_node*, tree_node*, vec**, tree_node*, int, int) ???:0 0xb685e4 build_throw(unsigned int, tree_node*) ???:0 0xc95e47 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x267035c pp_format(pretty_printer*, text_info*, urlifier const*) ???:0 0x2673055 pp_verbatim(pretty_printer*, char const*, ...) ???:0 0x26481ca diagnostic_context::report_diagnostic(diagnostic_info*) ???:0 0x26494c5 error_at(unsigned int, char const*, ...) ???:0 0xa7d834 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int) ???:0 0xa7eb5b build_special_member_call(tree_node*, tree_node*, vec**, tree_node*, int, int) ???:0 0xb685e4 build_throw(unsigned int, tree_node*) ???:0 0xc8b5c3 instantiate_decl(tree_node*, bool, bool) ???:0 0xcb56cb instantiate_pending_templates(int) ???:0 0xb54d39 c_parse_final_cleanups() ???:0 0xda8358 c_common_parse_file() ???:0=