[Bug c++/88554] [9 Regression] Segfault ICE when falling off the end of a reference-returning friend operator

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 19 17:37:00 GMT 2018


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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh that's definitely not right, because we don't want a fix-it for friend
functions, where *this isn't valid.

So this seems better:

--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -16092,6 +16092,7 @@ finish_function (bool inline_p)
        {
          tree valtype = TREE_TYPE (DECL_RESULT (fndecl));
          if (TREE_CODE (valtype) == REFERENCE_TYPE
+             && current_class_ref
              && same_type_ignoring_top_level_qualifiers_p
                  (TREE_TYPE (valtype), TREE_TYPE (current_class_ref)))
            if (global_dc->option_enabled (OPT_Wreturn_type,


More information about the Gcc-bugs mailing list