Skip to content

Commit

Permalink
[inplace_vector] Suppress GCC 11 bogus warning. NFCI.
Browse files Browse the repository at this point in the history
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98503
and duplicates seem to be related.

    inplace_vector.h:584:23: error: array subscript ‘sg14::inplace_vector<std::__cxx11::basic_string<char>, 5>[0]’
    is partly outside array bounds of ‘sg14::inplace_vector<std::__cxx11::basic_string<char>, 4> [1]’
    [-Werror=array-bounds]
      584 | set_size_(size_ - (oldend - newend));
          |           ^~~~~
  • Loading branch information
Quuxplusone committed Oct 20, 2023
1 parent 2ee020a commit 86ab9e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/sg14/inplace_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,19 @@ class inplace_vector : ipvbase_assignable<T>, ipvbase_t<T, N> {
iterator erase(const_iterator first, const_iterator last) {
auto ifirst = iterator(first);
auto ilast = iterator(last);
if (ifirst != ilast) {
auto n = ilast - ifirst;
if (n != 0) {
auto oldend = end();
#if defined(__cpp_lib_trivially_relocatable)
if constexpr (std::is_trivially_relocatable_v<value_type>) {
std::destroy(ifirst, ilast);
auto newend = std::uninitialized_relocate(ilast, oldend, ifirst);
set_size_(size_ - (oldend - newend));
std::uninitialized_relocate(ilast, oldend, ifirst);
set_size_(size_ - n);
return ifirst;
}
#endif // __cpp_lib_trivially_relocatable
auto newend = std::move(ilast, oldend, ifirst);
std::destroy(newend, oldend);
set_size_(size_ - (oldend - newend));
std::destroy(std::move(ilast, oldend, ifirst), oldend);
set_size_(size_ - n);
}
return ifirst;
}
Expand Down

0 comments on commit 86ab9e9

Please sign in to comment.