File: no_exceptions.cpp

package info (click to toggle)
frozen 1.2.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,244 kB
  • sloc: cpp: 18,992; ansic: 788; makefile: 77
file content (22 lines) | stat: -rw-r--r-- 551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <frozen/unordered_map.h>

#include <csignal>
#include <cstdlib>

// https://discourse.cmake.org/t/tests-that-are-meant-to-abort/537/3
// This is a hack to implement death tests in CTest.
extern "C" void error_test_handle_abort(int) { std::_Exit(EXIT_FAILURE); }

struct test_override_abort {
  test_override_abort() noexcept {
    std::signal(SIGABRT, error_test_handle_abort);
  }
};

test_override_abort handler{};

int main() {
  constexpr frozen::unordered_map<unsigned, unsigned, 2> ce = {{1, 2}, {3, 4}};
  ce.at(0xDEAD);
  return 0;
}