This is an archive of the discontinued LLVM Phabricator instance.

[flang][msvc] Define implicit conversion from UnsignedInt128 to int64_t.
ClosedPublic

Authored by Meinersbur on Sep 29 2020, 12:08 PM.

Details

Summary

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.

Diff Detail

Event Timeline

Meinersbur created this revision.Sep 29 2020, 12:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
Meinersbur requested review of this revision.Sep 29 2020, 12:08 PM
klausler accepted this revision.Sep 29 2020, 12:12 PM

Your "analogous conversion" from uint32 to int64 can't lose information, though.

This revision is now accepted and ready to land.Sep 29 2020, 12:12 PM

This is not really msvc specific, but also occurs with gcc when compiling with AVOID_NATIVE_UINT128_T.

Your "analogous conversion" from uint32 to int64 can't lose information, though.

I intended "conversion from uint32_t to int16_t". My mistake.

Meinersbur edited the summary of this revision. (Show Details)Sep 29 2020, 12:19 PM