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 via email to