On 3/31/25 4:59 PM, Marek Polacek wrote:
On Thu, Mar 27, 2025 at 11:27:04AM -0400, Jason Merrill wrote:
On 3/25/25 3:37 PM, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/14?

-- >8 --
Since r15-8011 cp_build_indirect_ref_1 won't do the *&TARGET_EXPR ->
TARGET_EXPR folding not to change its value category.  That fix is
correct but it made us stop extending the lifetime in this testcase,
causing a wrong-code issue -- extend_ref_init_temps_1 did not see
through the extra *& because it doesn't use a tree walk.  It is not
hard to fix that, but there may be other places that need this
adjustment.  :/

Hmm, this suggests to me that we should revert the 117512 patch and instead
fix it in build_over_call, perhaps by forcing 'val' to be an lvalue after
it's built rather than relying on 'to' being an lvalue already.

Thanks for the suggestion.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/14?

@@ -3870,13 +3870,11 @@ cp_build_indirect_ref_1 (location_t loc, tree ptr, 
ref_operator errorstring,
          return error_mark_node;
        }
        else if (do_fold && TREE_CODE (pointer) == ADDR_EXPR
-              && same_type_p (t, TREE_TYPE (TREE_OPERAND (pointer, 0)))
-              /* Don't let this change the value category.  '*&TARGET_EXPR'
-                 is an lvalue, but folding it into 'TARGET_EXPR' would turn
-                 it into a prvalue of class type.  */
-              && lvalue_p (TREE_OPERAND (pointer, 0)))
+              && same_type_p (t, TREE_TYPE (TREE_OPERAND (pointer, 0))))
        /* The POINTER was something like `&x'.  We simplify `*&x' to
-          `x'.  */
+          `x'.  This change the value category: '*&TARGET_EXPR'

"This might change" or "can change".  OK with that tweak.

Jason

Reply via email to