Skip to content

Commit b84696d

Browse files
authored
Fix the type of offset that broke 32-bit flang-rt build to use uint64_t consistently (#147359)
The recent change of `flang-rt` has code like `std::size_t offset{offset_};`. It broke the 32-bit `flang-rt` build because `Component::offset_` is of type `uint64_t` but `size_t` varies. Clang complains ``` error: non-constant-expression cannot be narrowed from type 'std::uint64_t' (aka 'unsigned long long') to 'std::size_t' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] 143 | std::size_t offset{offset_}; | ^~~~~~~ ``` This patch is to use the consistent `uint64_t` for offset.
1 parent f72e53f commit b84696d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

flang-rt/lib/runtime/assign.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ RT_API_ATTRS int DerivedAssignTicket<IS_COMPONENTWISE>::Continue(
598598
std::size_t componentByteSize{
599599
this->component_->SizeInBytes(this->instance_)};
600600
if (IS_COMPONENTWISE && toIsContiguous_ && fromIsContiguous_) {
601-
std::size_t offset{this->component_->offset()};
601+
std::size_t offset{
602+
static_cast<std::size_t>(this->component_->offset())};
602603
char *to{this->instance_.template OffsetElement<char>(offset)};
603604
const char *from{
604605
this->from_->template OffsetElement<const char>(offset)};
@@ -630,7 +631,8 @@ RT_API_ATTRS int DerivedAssignTicket<IS_COMPONENTWISE>::Continue(
630631
std::size_t componentByteSize{
631632
this->component_->SizeInBytes(this->instance_)};
632633
if (IS_COMPONENTWISE && toIsContiguous_ && fromIsContiguous_) {
633-
std::size_t offset{this->component_->offset()};
634+
std::size_t offset{
635+
static_cast<std::size_t>(this->component_->offset())};
634636
char *to{this->instance_.template OffsetElement<char>(offset)};
635637
const char *from{
636638
this->from_->template OffsetElement<const char>(offset)};

flang-rt/lib/runtime/type-info.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ RT_API_ATTRS void Component::CreatePointerDescriptor(Descriptor &descriptor,
140140
const SubscriptValue *subscripts) const {
141141
RUNTIME_CHECK(terminator, genre_ == Genre::Data);
142142
EstablishDescriptor(descriptor, container, terminator);
143-
std::size_t offset{offset_};
143+
std::size_t offset{static_cast<std::size_t>(offset_)};
144144
if (subscripts) {
145145
offset += container.SubscriptsToByteOffset(subscripts);
146146
}

0 commit comments

Comments
 (0)