https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116379
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:b01664a6197f57615d3c62594037c575dfdd9035 commit r15-7527-gb01664a6197f57615d3c62594037c575dfdd9035 Author: Marek Polacek <pola...@redhat.com> Date: Thu Feb 13 15:56:16 2025 -0500 c++: fix propagating REF_PARENTHESIZED_P [PR116379] Here we have: template<typename T> struct X{ T val; decltype(auto) value(){ return (val); } }; where the return type of value should be 'int &' since '(val)' is an expression, not a name, and decltype(auto) performs the type deduction using the decltype rules. The problem is that we weren't propagating REF_PARENTHESIZED_P correctly: the return value of finish_non_static_data_member in this test was a REFERENCE_REF_P, so we didn't set the flag. We should use force_paren_expr like below. PR c++/116379 gcc/cp/ChangeLog: * pt.cc (tsubst_expr) <COMPONENT_REF>: Use force_paren_expr to set REF_PARENTHESIZED_P. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/decltype-auto9.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com>