Fix a bug that affects 32-bit platforms.
Change-Id: If6751f35e018dfcf6caee2b59f6532753d914e7f
Reviewed-on: https://code-review.googlesource.com/c/re2/+/58831
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/prog.cc b/re2/prog.cc
index 3ad2a4a..e25a306 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -982,11 +982,11 @@
size_t dnext = 0;
while (states[dnext] != nnext)
++dnext;
- dfa[b] |= (dnext * 6) << (dcurr * 6);
+ dfa[b] |= static_cast<uint64_t>(dnext * 6) << (dcurr * 6);
// Convert ASCII letters to uppercase and record any extra transitions.
if ('a' <= b && b <= 'z') {
b -= 'a' - 'A';
- dfa[b] |= (dnext * 6) << (dcurr * 6);
+ dfa[b] |= static_cast<uint64_t>(dnext * 6) << (dcurr * 6);
}
}
}
@@ -994,7 +994,7 @@
// in the hot loop, we check for a match only at the end of each iteration,
// so we must keep signalling the match until we get around to checking it.
for (int b = 0; b < 256; ++b)
- dfa[b] |= (size * 6) << (size * 6);
+ dfa[b] |= static_cast<uint64_t>(size * 6) << (size * 6);
return dfa;
}