public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 2/2] Avoid default-initializing auto_vec<T, N> storage, fix vec<vl_embed>
Date: Fri, 24 Feb 2023 15:08:47 +0100	[thread overview]
Message-ID: <Y/jE72v6t7+8s0jG@tucnak> (raw)
In-Reply-To: <20230224134739.D386F13246@imap2.suse-dmz.suse.de>

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	other threads:[~2023-02-24 14:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 13:47 Richard Biener
2023-02-24 14:08 ` Jakub Jelinek [this message]
2023-02-24 14:13   ` Richard Biener
  -- strict thread matches above, loose matches on Subject: below --
2023-02-24 11:44 Richard Biener
2023-02-24 11:52 ` Jakub Jelinek
2023-02-24 11:54   ` Jonathan Wakely
2023-02-24 12:13     ` Jakub Jelinek
2023-02-24 12:15     ` Richard Biener
2023-02-24 12:26       ` Jakub Jelinek
2023-02-24 13:22       ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/jE72v6t7+8s0jG@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).