public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "arthur.j.odwyer at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-113789-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113789 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-eligible `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 that.) 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() = default; AutoPtr(AutoPtr&) {} }; template<class T> auto f(T p, int) -> decltype(throw p, 1) { throw p; } template<class T> 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*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ???:0 0xa7eb5b build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, 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*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ???:0 0xa7eb5b build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, 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
next reply other threads:[~2024-02-06 17:51 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-06 17:51 arthur.j.odwyer at gmail dot com [this message] 2024-02-06 17:59 ` [Bug c++/113789] " pinskia at gcc dot gnu.org 2024-02-06 18:16 ` mpolacek at gcc dot gnu.org 2024-02-06 18:16 ` [Bug c++/113789] [13/14 Regression] " mpolacek at gcc dot gnu.org 2024-02-06 20:32 ` mpolacek at gcc dot gnu.org 2024-02-06 22:32 ` mpolacek at gcc dot gnu.org 2024-02-06 22:32 ` mpolacek at gcc dot gnu.org 2024-02-07 4:35 ` arthur.j.odwyer at gmail dot com 2024-02-10 15:26 ` mpolacek at gcc dot gnu.org 2024-02-16 17:09 ` cvs-commit at gcc dot gnu.org 2024-02-16 17:14 ` [Bug c++/113789] [13 " mpolacek at gcc dot gnu.org 2024-02-16 17:53 ` arthur.j.odwyer at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113789-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).