Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a9c7722

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/compiler] Avoid undefined behavior in range analysis shift operation
Change-Id: I232f86b58c71746ea6ccb479f28d812c29027938 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127141 Reviewed-by: Vyacheslav Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
1 parent 413867d commit a9c7722

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

runtime/vm/compiler/backend/range_analysis.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,10 +1814,12 @@ RangeBoundary RangeBoundary::Shl(const RangeBoundary& value_boundary,
18141814
int64_t limit = 64 - shift_count;
18151815
int64_t value = value_boundary.ConstantValue();
18161816

1817-
if ((value == 0) || (shift_count == 0) ||
1818-
((limit > 0) && Utils::IsInt(static_cast<int>(limit), value))) {
1817+
if (value == 0) {
1818+
return RangeBoundary(0);
1819+
} else if (shift_count == 0 ||
1820+
(limit > 0 && Utils::IsInt(static_cast<int>(limit), value))) {
18191821
// Result stays in 64 bit range.
1820-
int64_t result = value << shift_count;
1822+
const int64_t result = value << shift_count;
18211823
return RangeBoundary(result);
18221824
}
18231825

0 commit comments

Comments
 (0)