Skip to content

Commit 74e11ac

Browse files
committed
Cast enum values back to size_t
This wasn't spotted until stage 3 of buildbots: having used `enum` to define all those constants, you now can't subtract one of them from another without provoking a warning about distinct integer types being used together. static_casting them all back to size_t makes the generic-abi-unstable build happy again.
1 parent b76d298 commit 74e11ac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libcxx/include/string

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ private:
853853
value_type v;
854854
};
855855
enum { __union_alignment = _LIBCPP_ALIGNOF(__union_alignment_check) };
856-
enum { __full_size = (__short_packed_size + __union_alignment - 1) & -__union_alignment };
856+
enum { __full_size = (static_cast<size_t>(__short_packed_size) + static_cast<size_t>(__union_alignment) - 1) & -static_cast<size_t>(__union_alignment) };
857857

858858
// Now define both structures for real, with padding to ensure they are both
859859
// exactly the calculated size.
@@ -868,14 +868,14 @@ private:
868868

869869
pointer __data_;
870870
size_type __size_;
871-
_LIBCPP_NO_UNIQUE_ADDRESS __padding<__full_size - sizeof(__long_min)> __padding_;
871+
_LIBCPP_NO_UNIQUE_ADDRESS __padding<static_cast<size_t>(__full_size) - sizeof(__long_min)> __padding_;
872872
size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
873873
size_type __is_long_ : 1;
874874
};
875875

876876
struct __short {
877877
value_type __data_[__min_cap];
878-
_LIBCPP_NO_UNIQUE_ADDRESS __padding<__full_size - __short_packed_size> __padding_;
878+
_LIBCPP_NO_UNIQUE_ADDRESS __padding<static_cast<size_t>(__full_size) - static_cast<size_t>(__short_packed_size)> __padding_;
879879
unsigned char __size_ : 7;
880880
unsigned char __is_long_ : 1;
881881
};

0 commit comments

Comments
 (0)