public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2
Date: Mon, 24 Oct 2022 18:07:05 +0000	[thread overview]
Message-ID: <bug-107276-4-RFKvi9q1jq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107276-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:f7d8ccfda2d5c90dac97b1a3ede8b10391a3cc40

commit r13-3462-gf7d8ccfda2d5c90dac97b1a3ede8b10391a3cc40
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Oct 20 15:55:28 2022 -0400

    c++: ICE with invalid structured bindings [PR107276]

    This test ICEs in C++23 because we reach the new code in do_auto_deduction:

    30468   if (cxx_dialect >= cxx23
    30469       && context == adc_return_type
    30470       && (!AUTO_IS_DECLTYPE (auto_node)
    30471           || !unparenthesized_id_or_class_member_access_p (init))
    30472       && (r = treat_lvalue_as_rvalue_p (maybe_undo_parenthesized_ref
(init),
    30473                                         /*return*/true)))

    where 'init' is "VIEW_CONVERT_EXPR<<<< error >>>>(y)", and then the move
    in treat_lvalue_as_rvalue_p returns error_mark_node whereupon
    set_implicit_rvalue_p crashes.

    I don't think such V_C_Es are useful so let's not create them.  But that
    won't fix the ICE so I'm checking the return value of move.  A structured
    bindings decl can have an error type, that is set in cp_finish_decomp:

     8908           TREE_TYPE (first) = error_mark_node;

    therefore I think treat_lvalue_as_rvalue_p just needs to cope.

            PR c++/107276

    gcc/cp/ChangeLog:

            * typeck.cc (treat_lvalue_as_rvalue_p): Check the return value of
move.

    gcc/ChangeLog:

            * tree.cc (maybe_wrap_with_location): Don't create a location
wrapper
            when the type is erroneous.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/decomp4.C: New test.

  parent reply	other threads:[~2022-10-24 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-16  0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
2022-10-17 11:29 ` [Bug c++/107276] ICE Deducing " marxin at gcc dot gnu.org
2022-10-19 18:35 ` johelegp at gmail dot com
2022-10-20 11:10 ` [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2 marxin at gcc dot gnu.org
2022-10-20 12:57 ` mpolacek at gcc dot gnu.org
2022-10-24 18:07 ` cvs-commit at gcc dot gnu.org [this message]
2022-10-24 18:08 ` mpolacek at gcc dot gnu.org

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-107276-4-RFKvi9q1jq@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: link
Be 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).