https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88554
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- This fixes the ICE but I don't know if it's right and haven't tested it any further: --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -16093,7 +16093,7 @@ finish_function (bool inline_p) tree valtype = TREE_TYPE (DECL_RESULT (fndecl)); if (TREE_CODE (valtype) == REFERENCE_TYPE && same_type_ignoring_top_level_qualifiers_p - (TREE_TYPE (valtype), TREE_TYPE (current_class_ref))) + (TREE_TYPE (valtype), current_class_type)) if (global_dc->option_enabled (OPT_Wreturn_type, global_dc->option_state)) add_return_star_this_fixit (&richloc, fndecl);