Skip to content

Commit b554306

Browse files
committed
[flang][msvc] Define implicit conversion from UnsignedInt128 to int64_t.
The custom implementation of UnsignedInt128 has an implicit conversion operator to unit64_t, but not int64_t. Considering that the former is already truncating, and C++ implicitly converts uint64_t to int64_t, UnsignedInt128 should also support an implicit conversion to int64_t. An analogous conversion would be from uint32_t to int16_t. Without the conversion operator overload, the msvc emits the following error: ``` descriptor-io.h(44): error C2440: 'static_cast': cannot convert from 'A' to 'int64_t' with [ A=Fortran::common::uint128_t ] ``` This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html>. Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D88509
1 parent 80381c4 commit b554306

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

flang/include/flang/Common/uint128.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class UnsignedInt128 {
5353
constexpr bool operator!() const { return !low_ && !high_; }
5454
constexpr explicit operator bool() const { return low_ || high_; }
5555
constexpr explicit operator std::uint64_t() const { return low_; }
56+
constexpr explicit operator std::int64_t() const { return low_; }
5657
constexpr explicit operator int() const { return static_cast<int>(low_); }
5758

5859
constexpr std::uint64_t high() const { return high_; }

0 commit comments

Comments
 (0)