* constexpr.c (cxx_eval_builtin_function_call): Only defer
__builtin_constant_p if ctx->quiet.
From-SVN: r259051
+2018-04-03 Jason Merrill <jason@redhat.com>
+
+ PR c++/85113 - ICE with constexpr and __builtin_constant_p.
+ * constexpr.c (cxx_eval_builtin_function_call): Only defer
+ __builtin_constant_p if ctx->quiet.
+
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768
/* Don't fold __builtin_constant_p within a constexpr function. */
bool bi_const_p = (DECL_FUNCTION_CODE (fun) == BUILT_IN_CONSTANT_P);
+ /* If we aren't requiring a constant expression, defer __builtin_constant_p
+ in a constexpr function until we have values for the parameters. */
if (bi_const_p
+ && ctx->quiet
&& current_function_decl
&& DECL_DECLARED_CONSTEXPR_P (current_function_decl))
{
--- /dev/null
+// PR c++/85113
+// { dg-do compile { target c++14 } }
+
+template<bool> struct A {};
+
+constexpr int foo()
+{
+ A<__builtin_constant_p(0)> a{};
+ return 0;
+}