Skip to content

Commit

Permalink
Patch fix for using fmt with GCC 13
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmalyshev committed Aug 16, 2023
1 parent afd2bed commit 0b547d0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ThirdParty/fmt-8.1.1/include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ FMT_INLINE void assume(bool condition) {
(void)condition;
#if FMT_HAS_BUILTIN(__builtin_assume)
__builtin_assume(condition);
#elif FMT_GCC_VERSION
if (!condition) __builtin_unreachable();
#endif
}

Expand Down Expand Up @@ -789,9 +791,9 @@ FMT_CONSTEXPR20 void basic_memory_buffer<T, SIZE, Allocator>::grow(
T* old_data = this->data();
T* new_data =
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
detail::assume(this->size() <= new_capacity);
// The following code doesn't throw, so the raw pointer above doesn't leak.
std::uninitialized_copy(old_data, old_data + this->size(),
detail::make_checked(new_data, new_capacity));
std::uninitialized_copy_n(old_data, this->size(), new_data);
this->set(new_data, new_capacity);
// deallocate must not throw according to the standard, but even if it does,
// the buffer already uses the new storage and will deallocate it in
Expand Down

0 comments on commit 0b547d0

Please sign in to comment.