On Fri, Feb 24, 2023 at 02:47:39PM +0100, Richard Biener wrote:
>       * vec.h (vec<T, A, vl_embed>::m_vecdata): Remove.
>       (vec<T, A, vl_embed>::m_vecpfx): Align as T to avoid
>       changing alignment of vec<T, A, vl_embed> and simplifying
>       address.
>       (vec<T, A, vl_embed>::address): Compute as this + 1.
>       (vec<T, A, vl_embed>::embedded_size): Use sizeof the
>       vector instead of the offset of the m_vecdata member.
>       (auto_vec<T, N>::m_data): Turn storage into
>       uninitialized unsigned char.
>       (auto_vec<T, N>::auto_vec): Allow allocation of one
>       stack member.  Initialize m_vec in a special way to
>       avoid later stringop overflow diagnostics.
>       * vec.cc (test_auto_alias): New.
>       (vec_cc_tests): Call it.
> @@ -1559,8 +1560,14 @@ class auto_vec : public vec<T, va_heap>
>  public:
>    auto_vec ()
>    {
> -    m_auto.embedded_init (MAX (N, 2), 0, 1);
> -    this->m_vec = &m_auto;
> +    m_auto.embedded_init (N, 0, 1);
> +    /* ???  Instead of initializing m_vec from &m_auto directly use an
> +       expression that avoids refering to a specific member of 'this'
> +       to derail the -Wstringop-overflow diagnostic code, avoiding
> +       the impression that data accesses are supposed to be to the
> +       m_auto memmber storage.  */

s/memmber/member/

> +    size_t off = (char *) &m_auto - (char *) this;
> +    this->m_vec = (vec<T, va_heap, vl_embed> *) ((char *) this + off);
>    }
>  
>    auto_vec (size_t s CXX_MEM_STAT_INFO)
> @@ -1571,7 +1578,7 @@ public:
>       return;
>        }
>  
> -    m_auto.embedded_init (MAX (N, 2), 0, 1);
> +    m_auto.embedded_init (N, 0, 1);
>      this->m_vec = &m_auto;

Don't we need the above 2 lines here as well (perhaps with a shorter comment
just referencing the earlier comment)?

Otherwise LGTM, thanks.

        Jakub

Reply via email to