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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Well, if we are Ok with loosening a bit the gcc_assert which is firing for such
targets, I don't think we risk miscompiling anything, I think we are already
handling correctly the case of a return in user code which boils down to a goto
to a label immediately followed by return this.

I'm adding Jakub in CC, he hacked quite a bit related constexpr.c code in order
to completely fix constexpr-77467.C

Index: constexpr.c
===================================================================
--- constexpr.c (revision 251607)
+++ constexpr.c (working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "target.h"
 #include "cp-tree.h"
 #include "varasm.h"
 #include "c-family/c-objc.h"
@@ -4554,7 +4555,14 @@ cxx_eval_constant_expression (const constexpr_ctx

     case GOTO_EXPR:
       *jump_target = TREE_OPERAND (t, 0);
-      gcc_assert (breaks (jump_target) || continues (jump_target));
+      gcc_assert (breaks (jump_target) || continues (jump_target)
+                 /* Allow for jumping to a cdtor_label.  */
+                 || (targetm.cxx.cdtor_returns_this ()
+                     && *jump_target
+                     && TREE_CODE (*jump_target) == LABEL_DECL
+                     && DECL_ARTIFICIAL (*jump_target)
+                     && (DECL_CONSTRUCTOR_P (DECL_CONTEXT (*jump_target))
+                         || DECL_DESTRUCTOR_P (DECL_CONTEXT
(*jump_target)))));
       break;

     case LOOP_EXPR:

Reply via email to