# define _GLIBCXX_EXTERN_TEMPLATE -1
#endif
+
+#if __has_builtin(__builtin_is_constant_evaluated)
+# define __glibcxx_constexpr_assert(cond) \
+ if (__builtin_is_constant_evaluated() && !bool(cond)) \
+ __builtin_unreachable() /* precondition violation detected! */
+#else
+# define __glibcxx_constexpr_assert(unevaluated)
+#endif
+
+
// Assert.
#if defined(_GLIBCXX_ASSERTIONS) \
|| defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS)
}
#define __glibcxx_assert_impl(_Condition) \
if (__builtin_expect(!bool(_Condition), false)) \
+ { \
+ __glibcxx_constexpr_assert(_Condition); \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
- #_Condition)
+ #_Condition); \
+ }
#endif
#if defined(_GLIBCXX_ASSERTIONS)
-# define __glibcxx_assert_2(_Condition) __glibcxx_assert_impl(_Condition)
+# define __glibcxx_assert(cond) \
+ do { __glibcxx_assert_impl(cond); } while (false)
#else
-# define __glibcxx_assert_2(_Condition)
+# define __glibcxx_assert(cond) \
+ do { __glibcxx_constexpr_assert(cond); } while (false)
#endif
// Macros for race detectors.
#undef _GLIBCXX_HAS_BUILTIN
-#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >= 201402L
-# define __glibcxx_assert_1(_Condition) \
- if (__builtin_is_constant_evaluated()) \
- { \
- void __failed_assertion(); \
- if (!bool(_Condition)) \
- __failed_assertion(); \
- } \
- else
-#else
-# define __glibcxx_assert_1(_Condition)
-#endif
-
-# define __glibcxx_assert(_Condition) \
- do { \
- __glibcxx_assert_1(_Condition) \
- { __glibcxx_assert_2(_Condition); } \
- } while (false)
-
// PSTL configuration
#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
do { \
- __glibcxx_assert_1(_Cond) \
- { _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); } \
+ __glibcxx_constexpr_assert(_Cond); \
+ _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); \
} while (false)
#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \