Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprecision: ignore buggy -Waggressive-loop-optimizations in subtraction #334

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ namespace nil::crypto3::multiprecision {
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
// Disable a false positive triggered by
// -Waggressive-loop-optimizations
// -Waggressive-loop-optimizations.
//
// The warning message is "warning:
// iteration 2305843009213693951 invokes undefined behavior
// [-Waggressive-loop-optimizations]"
// [-Waggressive-loop-optimizations]".
//
// Of course if i becomes 2^61
// uint64_t will overflow, this is expected
// uint64_t will overflow, this is expected.
//
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100801
#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations"
#endif

Expand Down Expand Up @@ -285,7 +287,27 @@ namespace nil::crypto3::multiprecision {
borrow = subborrow(borrow, pa[i + 3], pb[i + 3], pr + i + 3);
}
for (; i < m; ++i) {
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
// Disable a false positive triggered by
// -Waggressive-loop-optimizations.
//
// The warning message is "warning:
// iteration 2305843009213693951 invokes undefined behavior
// [-Waggressive-loop-optimizations]".
//
// Of course if i becomes 2^61
// uint64_t will overflow, this is expected.
//
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100801
#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations"
#endif

borrow = subborrow(borrow, pa[i], pb[i], pr + i);

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
// Now where only a has digits, only as long as we've borrowed:
while (borrow && (i < as)) {
Expand Down