[flang-commits] [flang] [flang][runtime] Fix integer overflow check for FORMATs (PR #79471)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 25 09:14:54 PST 2024
================
@@ -85,8 +85,8 @@ int FormatControl<CONTEXT>::GetIntField(
ch = PeekNext();
}
while (ch >= '0' && ch <= '9') {
- if (result >
- std::numeric_limits<int>::max() / 10 - (static_cast<int>(ch) - '0')) {
+ constexpr int tenth{std::numeric_limits<int>::max() / 10};
+ if (result > tenth || ch - '0' > std::numeric_limits<int>::max() - result) {
----------------
klausler wrote:
Right, sorry; will fix.
https://github.com/llvm/llvm-project/pull/79471
More information about the flang-commits
mailing list