5#ifndef BITCOIN_UTIL_CHECK_H
6#define BITCOIN_UTIL_CHECK_H
8#if defined(HAVE_CONFIG_H)
9#include <config/bitcoin-config.h>
18 using std::runtime_error::runtime_error;
21#define format_internal_error(msg, file, line, func, report) \
22 strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this " \
24 msg, file, line, func, report)
29 const char *func,
const char *assertion) {
32 assertion, file, line, func, PACKAGE_BUGREPORT));
35 return std::forward<T>(val);
53#define CHECK_NONFATAL(condition) \
54 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
57#error "Cannot compile without assertions!"
62 const char *assertion);
65template <
bool IS_ASSERT,
typename T>
67 [[maybe_unused]]
const char *file,
68 [[maybe_unused]]
int line,
69 [[maybe_unused]]
const char *func,
70 [[maybe_unused]]
const char *assertion) {
71 if constexpr (IS_ASSERT
72#ifdef ABORT_ON_FAILED_ASSUME
80 return std::forward<T>(val);
85 inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
98 inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
106#define NONFATAL_UNREACHABLE() \
107 throw NonFatalCheckError(format_internal_error( \
108 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__, \
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
#define format_internal_error(msg, file, line, func, report)
T && inline_assertion_check(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for Assert()/Assume()
void assertion_fail(const char *file, int line, const char *func, const char *assertion)
Helper for Assert()