So while debugging PR 118320, I found it was useful to have
an assert inside array_slice::begin/end that the array slice isvalid
rather than getting an segfault. This adds an assert that is only
enabled for checking.
OK? Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* vec.h (array_slice::begin): Assert that the
slice is valid.
(array_slice::end): Likewise.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
array_slice (vec<OtherT, A, vl_embed> *v)
: m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {}
- iterator begin () { return m_base; }
- iterator end () { return m_base + m_size; }
+ iterator begin () { gcc_checking_assert (is_valid ()); return m_base; }
+ iterator end () { gcc_checking_assert (is_valid ()); return m_base + m_size; }
- const_iterator begin () const { return m_base; }
- const_iterator end () const { return m_base + m_size; }
+ const_iterator begin () const { gcc_checking_assert (is_valid ()); return m_base; }
+ const_iterator end () const { gcc_checking_assert (is_valid ()); return m_base + m_size; }
value_type &front ();
value_type &back ();