Skip to content

Commit 71a17ed

Browse files
LT2Hhsutter
andauthored
Add runtime check for modulo by zero (#1405)
* Add runtime check for modulo by zero * Rerun regression tests One of the tests now hits an MSVC error I've seen before, related to using std::source_location via module std import -- it doesn't manifest on any other compiler, or in MSVC using std headers. So the error is spurious, but I'm not able to debug it or find a workaround, and I don't want to record regression test failures just because of that use case where 'module std currently doesn't work.' So this commit also changes all -pure regression tests to use headers, not modules, at least for now until modules work better --------- Co-authored-by: Herb Sutter <[email protected]>
1 parent 66581b0 commit 71a17ed

File tree

116 files changed

+120
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+120
-118
lines changed

regression-tests/test-results/mixed-initialization-safety-3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ auto print_decorated(auto const& x) -> void{
6868
}
6969

7070
#line 32 "mixed-initialization-safety-3.cpp2"
71-
[[nodiscard]] auto flip_a_coin() -> bool { return std::mt19937()() % 2 == 0; }
71+
[[nodiscard]] auto flip_a_coin() -> bool { return std::mt19937()() % CPP2_ASSERT_NOT_ZERO_LITERAL(CPP2_TYPEOF(std::mt19937()()),2) == 0; }
7272

regression-tests/test-results/mixed-parameter-passing-with-forward.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ requires (std::is_convertible_v<CPP2_TYPEOF(e), std::add_const_t<std::string>&>)
5656
++z;
5757
b += "plugh";
5858

59-
if (std::rand() % 2) {
59+
if (std::rand() % CPP2_ASSERT_NOT_ZERO_LITERAL(CPP2_TYPEOF(std::rand()),2)) {
6060
++z;
6161
copy_from(cpp2::move(b));// definite last use
6262
}
@@ -71,7 +71,7 @@ requires (std::is_convertible_v<CPP2_TYPEOF(e), std::add_const_t<std::string>&>)
7171

7272
copy_from(z);
7373

74-
if (std::time(nullptr) % 2 == 0) {
74+
if (std::time(nullptr) % CPP2_ASSERT_NOT_ZERO_LITERAL(CPP2_TYPEOF(std::time(nullptr)),2) == 0) {
7575
copy_from(cpp2::move(z));
7676
}
7777

regression-tests/test-results/mixed-parameter-passing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ auto parameter_styles(
6969
++z;
7070
b += "plugh";
7171

72-
if (std::rand() % 2) {
72+
if (std::rand() % CPP2_ASSERT_NOT_ZERO_LITERAL(CPP2_TYPEOF(std::rand()),2)) {
7373
++z;
7474
copy_from(cpp2::move(b));// definite last use
7575
}
@@ -83,7 +83,7 @@ auto parameter_styles(
8383

8484
copy_from(z);
8585

86-
if (std::time(nullptr) % 2 == 0) {
86+
if (std::time(nullptr) % CPP2_ASSERT_NOT_ZERO_LITERAL(CPP2_TYPEOF(std::time(nullptr)),2) == 0) {
8787
copy_from(cpp2::move(z));
8888
}
8989

regression-tests/test-results/pure2-assert-expected-not-null.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-assert-optional-not-null.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-assert-shared-ptr-not-null.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-assert-unique-ptr-not-null.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-bounds-safety-span.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-break-continue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

regression-tests/test-results/pure2-bugfix-for-assign-expression-list.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#define CPP2_IMPORT_STD Yes
2+
#define CPP2_INCLUDE_STD Yes
33

44
//=== Cpp2 type declarations ====================================================
55

0 commit comments

Comments
 (0)