Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/gul17/SmallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,15 @@ class SmallVector
::new(static_cast<void*>(p)) ValueType(value);
}

// GCC 16's interprocedural array-bounds analysis can be confused when data_end() is
// inlined into code that constructs a SmallVector as an alternative of a
// std::variant. It then emits a false-positive "array subscript is outside array
// bounds" warning (see #57), so we silence -Warray-bounds.
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds"
#endif

/// Return a non-dereferenceable pointer past the last element.
constexpr ValueType* data_end() noexcept
{
Expand All @@ -1313,6 +1322,10 @@ class SmallVector
return data_ptr_ + size_;
}

#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
#endif

/// Deallocate aligned memory that was reserved with allocate_space_for_elements().
static void deallocate_space_for_elements(ValueType* ptr) noexcept
{
Expand Down
Loading