FE
0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
Toggle main menu visibility
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cassert>
4
#include <cstdlib>
5
6
namespace
fe
{
7
8
/// @sa https://stackoverflow.com/a/65258501
9
#ifdef __GNUC__
// GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above)
10
[[noreturn]]
inline
__attribute__((always_inline))
void
unreachable
() {
11
assert(
false
);
12
__builtin_unreachable();
13
}
14
#elif defined(_MSC_VER)
// MSVC
15
[[noreturn]] __forceinline
void
unreachable
() {
16
assert(
false
);
17
__assume(
false
);
18
}
19
#else
// ???
20
[[noreturn]]
inline
void
unreachable
() {
21
assert(
false
);
22
std::abort();
23
}
24
#endif
25
26
/// Raise a breakpoint in the debugger.
27
#if (defined(__clang__) || defined(__GNUC__)) && (defined(__x86_64__) || defined(__i386__))
28
inline
void
breakpoint
() {
asm
(
"int3"
); }
29
#else
30
inline
void
breakpoint
() {
31
volatile
int
* p =
nullptr
;
32
*p = 42;
33
}
34
#endif
35
36
}
// namespace fe
37
38
#ifndef NDEBUG
39
# define assert_unused(x) assert(x)
40
#else
41
# define assert_unused(x) ((void)(0 && (x)))
42
#endif
fe
Definition
algo.h:17
fe::breakpoint
void breakpoint()
Raise a breakpoint in the debugger.
Definition
assert.h:30
fe::unreachable
void unreachable()
Definition
assert.h:20
fe
assert.h
Generated by
1.18.0