[all-commits] [llvm/llvm-project] c53117: Fix invalid overflow check in flang
serge-sans-paille via All-commits
all-commits at lists.llvm.org
Wed Mar 30 07:47:54 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c531171d995728f55e5775d354a21dceed03edce
https://github.com/llvm/llvm-project/commit/c531171d995728f55e5775d354a21dceed03edce
Author: serge-sans-paille <sguelton at redhat.com>
Date: 2022-03-30 (Wed, 30 Mar 2022)
Changed paths:
M flang/runtime/command.cpp
Log Message:
-----------
Fix invalid overflow check in flang
Statically checking for overflow with
if constexpr (sizeof(std::size_t) <= sizeof(std::int64_t)) {
return static_cast<std::int64_t>(length);
}
Doesn't work if `sizeof(std::size_t) == sizeof(std::int64_t)` because std::size_t
is unsigned.
if `length == std::numeric_limits<size_t>` casting it to `int64_t` is going to overflow.
This code would be much simpler if returning a `uint64_t` instead of a signed
value...
Differential Revision: https://reviews.llvm.org/D122705
More information about the All-commits
mailing list