Skip to content

Commit dce4555

Browse files
yfeldblummeta-codesync[bot]
authored andcommitted
let F14Table::size explicitly be size_t
Summary: Closes: facebook/folly#2551. The `F14Table::iterator` type packs the size in with other table metadata into `uint64_t`. But it is possible on some platforms for `size_t` to be smaller than `uint64_t`, making some uses of the result of `size()` into implicit narrowing casts. The size of the table cannot be larger than is representable by `size_t` but due to the bit-packing and shifting we still need the `uint64_t` representation. So let `F14Table::size()` explicitly cast. Reviewed By: r-barnes Differential Revision: D93896663 fbshipit-source-id: 39e55b8d21056fcd43b0fdba942603be9953634b
1 parent 2426260 commit dce4555

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • third-party/folly/src/folly/container/detail

third-party/folly/src/folly/container/detail/F14Table.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,9 @@ class F14Table : public Policy {
15791579

15801580
bool empty() const noexcept { return size() == 0; }
15811581

1582-
auto size() const noexcept { return sizeAndChunkShiftAndPackedBegin_.size(); }
1582+
std::size_t size() const noexcept {
1583+
return to_narrow(sizeAndChunkShiftAndPackedBegin_.size());
1584+
}
15831585

15841586
std::size_t max_size() const noexcept {
15851587
auto& a = this->alloc();

0 commit comments

Comments
 (0)