public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94264] Array-to-pointer conversion not performed on array prvalues
Date: Sat, 18 Apr 2020 16:33:54 +0000	[thread overview]
Message-ID: <bug-94264-4-7kdddeYDOj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94264-4@http.gcc.gnu.org/bugzilla/>

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-04-18
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
cp_build_binary_op calls cp_default_conversion on its operands and that calls
decay_conversion which has:

 2153       /* Don't let an array compound literal decay to a pointer.  It can
 2154          still be used to initialize an array or bind to a reference.  */
 2155       if (TREE_CODE (exp) == TARGET_EXPR)
 2156         {
 2157           if (complain & tf_error)
 2158             error_at (loc, "taking address of temporary array");
 2159           return error_mark_node;
 2160         }


convert_like_real does

+   /* Take the address explicitly rather than via decay_conversion
+      to avoid the error about taking the address of a temporary.  */
+   array = cp_build_addr_expr (array, complain);
+   array = cp_convert (build_pointer_type (elttype), array);

to avoid that error.

  reply	other threads:[~2020-04-18 16:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23  0:21 [Bug c++/94264] New: " ndkrempel at gmail dot com
2020-04-18 16:33 ` mpolacek at gcc dot gnu.org [this message]
2021-08-10  3:43 ` [Bug c++/94264] " pinskia at gcc dot gnu.org
2021-10-02 20:01 ` pinskia at gcc dot gnu.org
2023-10-08  7:31 ` fchelnokov at gmail dot com
2023-10-09  2:07 ` de34 at live dot cn
2023-10-09  2:19 ` pinskia at gcc dot gnu.org
2023-11-28 18:05 ` jason at gcc dot gnu.org
2023-11-28 21:29 ` cvs-commit at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2023-12-19 20:54 ` jason 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-94264-4-7kdddeYDOj@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).