https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116379
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:385482a2d70c13f2741f0fede95de93eefd63f1d commit r13-10474-g385482a2d70c13f2741f0fede95de93eefd63f1d Author: Marek Polacek <[email protected]> Date: Thu Aug 20 14:59:46 2026 -0400 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 <[email protected]>
