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

--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Created attachment 63479
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63479&action=edit
pr123738.patch

Issue is in 'cp_fold_non_odr_use_1', when called to fold away a reference,
considers the use to not be an lvalue and so 'maybe_constant_value' folds all
the way through the nested INDIRECT_REF to a prvalue.

The attached (somewhat tested, so far just dg.exp) fix seems to solve the
issue, but I'm not sure if there's a better way to teach
cxx_eval_outermost_constant_expr that we want an lvalue evaluation, or whether
we should provide a new function specifically for folding reference usages.

Reply via email to