Sorry for being late with my comment.  I just spotted this minor
formatting issue.  Even though GCC isn't (yet) consistent about
it the keyword "constexpr" should be quoted in the error message
below (and, eventually, in all diagnostic messages).  Since the
patch has been committed by now this is just a reminder for us
to try to keep this in mind in the future.

Martin

--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1180,9 +1180,18 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
     {
       if (!*non_constant_p && !ctx->quiet)
        {
-         new_call = build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
-                                          CALL_EXPR_FN (t), nargs, args);
-         error ("%q+E is not a constant expression", new_call);
+         /* Do not allow__builtin_unreachable in constexpr function.
+            The __builtin_unreachable call with BUILTINS_LOCATION
+            comes from cp_maybe_instrument_return.  */
+         if (DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
+             && EXPR_LOCATION (t) == BUILTINS_LOCATION)
+           error ("constexpr call flows off the end of the function");

Reply via email to