File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
tests/GH_005816_numeric_limits_traps Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,7 @@ tests\GH_005472_do_not_overlap
272272tests\GH_005546_containers_size_type_cast
273273tests\GH_005553_regex_character_translation
274274tests\GH_005768_pow_accuracy
275+ tests\GH_005816_numeric_limits_traps
275276tests\LWG2381_num_get_floating_point
276277tests\LWG2510_tag_classes
277278tests\LWG2597_complex_branch_cut
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation.
2+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ RUNALL_INCLUDE ..\usual_matrix.lst
Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation.
2+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ #include < limits>
5+
6+ #include < test_death.hpp>
7+
8+ #ifdef __clang__
9+ #pragma clang diagnostic ignored "-Wc++17-extensions" // constexpr if is a C++17 extension
10+ #else
11+ #pragma warning(disable : 4984) // warning C4984: 'if constexpr' is a C++17 language extension
12+ #endif // __clang__
13+
14+ void trap_operation () {
15+ volatile int op1{1 };
16+ volatile int op2{0 };
17+ volatile int res = op1 / op2;
18+ (void ) res;
19+ }
20+
21+ int main (int argc, char * argv[]) {
22+ if constexpr (std::numeric_limits<int >::traps) {
23+ std_testing::death_test_executive exec;
24+ const std_testing::death_function_t one_trap[] = {trap_operation};
25+ exec.add_death_tests (one_trap);
26+ return exec.run (argc, argv);
27+ } else {
28+ trap_operation ();
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments