mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
23 lines
547 B
C++
23 lines
547 B
C++
// https://cirosantilli.com/linux-kernel-module-cheat#cpp
|
||
|
||
constexpr int f() {
|
||
int i = 0;
|
||
while (1)
|
||
i += 1;
|
||
return i;
|
||
}
|
||
|
||
constexpr int g() {
|
||
return g();
|
||
}
|
||
|
||
|
||
int main() {
|
||
#if 0
|
||
// GCC 9.2.1. error: ‘constexpr’ loop iteration count exceeds limit of 262144 (use ‘-fconstexpr-loop-limit=’ to increase the limit)
|
||
static_assert(f() == 0);
|
||
// GCC 9.2.1. error: ‘constexpr’ evaluation depth exceeds maximum of 512 (use ‘-fconstexpr-depth=’ to increase the maximum)
|
||
static_assert(g() == 0);
|
||
#endif
|
||
}
|