r16-968-g5c6364b09a6 has added if (DECL_ARTIFICIAL (*target)) return true;
stmt for GOTO_EXPRs. This unfortunately ICEs if *target is not a decl,
which is the case for computed gotos. For those we should always reject
them, so the following patch additionally checks for LABEL_DECL
before testing DECL_ARTIFICIAL on it.
2026-01-14 Jakub Jelinek <jakub@redhat.com>
PR c++/123551
* constexpr.cc (potential_constant_expression_1) <case GOTO_EXPR>:
Only test DECL_ARTIFICIAL on LABEL_DECLs.
* g++.dg/ext/goto2.C: New test.
*jump_target = *target;
return true;
}
- if (DECL_ARTIFICIAL (*target))
+ if (TREE_CODE (*target) == LABEL_DECL && DECL_ARTIFICIAL (*target))
/* The user didn't write this goto, this isn't the problem. */
return true;
if (flags & tf_error)
--- /dev/null
+// PR c++/123551
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+void
+foo ()
+{
+ [] () {
+ void *a = &&b;
+ goto *a;
+ b:;
+ };
+}