https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121583
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that apply_deduced_return_type
has
if (!processing_template_decl)
if (function *fun = DECL_STRUCT_FUNCTION (fco))
{
bool aggr = aggregate_value_p (result, fco);
#ifdef PCC_STATIC_STRUCT_RETURN
fun->returns_pcc_struct = aggr;
#endif
fun->returns_struct = aggr;
}
In the above testcase, apply_deduced_return_type is called when parsing the
expansion stmt body, which is done with processing_template_decl. When
actually instantiating
the body, check_return_expr is called again but as the auto type has been
resolved by then, apply_deduced_return_type is not called again and so
fun->returns_{,pcc_}struct
remains to be incorrectly set.
Bet the !processing_template_decl here is meant as a shorthand for
!decl_dependent_p (current_function_decl).