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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Since r246954 we treat array prvalues like class prvalues.  So this
2054       if (!obvalue_p (exp)
2055           && ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
2056         {
2057           if (complain & tf_error)
2058             error_at (loc, "invalid use of non-lvalue array");
2059           return error_mark_node;
2060         }
in decay_conversion no longer triggers because obvalue_p is now 1.
cp_build_addr_expr_1 says
    If STRICT_LVALUE is true, require an lvalue; otherwise, allow xvalues
    and class rvalues as well.
so I'm not sure if we should allow array rvalues too.  If not then perhaps

--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5760,7 +5760,7 @@ build_nop (tree type, tree expr)

 /* Take the address of ARG, whatever that means under C++ semantics.
    If STRICT_LVALUE is true, require an lvalue; otherwise, allow xvalues
-   and class rvalues as well.
+   and class and array rvalues as well.

    Nothing should call this function directly; instead, callers should use
    cp_build_addr_expr or cp_build_addr_expr_strict.  */
@@ -5842,7 +5842,9 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue,
tsubst_flags_t complain)
       && TREE_CODE (argtype) != METHOD_TYPE)
     {
       cp_lvalue_kind kind = lvalue_kind (arg);
-      if (kind == clk_none)
+      if (kind == clk_none
+     || (kind == clk_class
+         && TREE_CODE (argtype) == ARRAY_TYPE))
    {
      if (complain & tf_error)
        lvalue_error (input_location, lv_addressof);

Reply via email to