From: David Malcolm <dmalcolm@redhat.com>
To: Martin Sebor <msebor@gmail.com>, Jason Merrill <jason@redhat.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] make rich_location safe to copy
Date: Wed, 16 Jun 2021 14:50:43 -0400 [thread overview]
Message-ID: <5c4ca226721bb05eb9403fc154755ae8e6243e71.camel@redhat.com> (raw)
In-Reply-To: <8471bbb6-df84-5afc-eee2-70f844ff1df0@gmail.com>
On Wed, 2021-06-16 at 11:21 -0600, Martin Sebor wrote:
> On 6/16/21 10:35 AM, Jason Merrill wrote:
> > On 6/16/21 12:11 PM, Martin Sebor wrote:
> > > On 6/16/21 9:06 AM, David Malcolm wrote:
> > > > On Wed, 2021-06-16 at 08:52 -0600, Martin Sebor wrote:
> > > > > On 6/16/21 6:38 AM, David Malcolm wrote:
> > > > > > On Tue, 2021-06-15 at 19:48 -0600, Martin Sebor wrote:
> > > > > >
> > > > > > Thanks for writing the patch.
> > > > > >
> > > > > > > While debugging locations I noticed the semi_embedded_vec
> > > > > > > template
> > > > > > > in line-map.h doesn't declare a copy ctor or copy
> > > > > > > assignment, but
> > > > > > > is being copied in a couple of places in the C++ parser
> > > > > > > (via
> > > > > > > gcc_rich_location). It gets away with it most likely
> > > > > > > because it
> > > > > > > never grows beyond the embedded buffer.
> > > > > >
> > > > > > Where are these places? I wasn't aware of this.
> > > > >
> > > > > They're in the attached file along with the diff to reproduce
> > > > > the errors.
> > > >
> > > > Thanks.
> > > >
> > > > Looks like:
> > > >
> > > > gcc_rich_location richloc = tok->location;
> > > >
> > > > is implicitly constructing a gcc_rich_location, then copying it
> > > > to
> > > > richloc. This should instead be simply:
> > > >
> > > > gcc_rich_location richloc (tok->location);
> > > >
> > > > which directly constructs the richloc in place, as I understand
> > > > it.
> > >
> > > I see, tok->location is location_t here, and the
> > > gcc_rich_location
> > > ctor that takes it is not declared explicit (that would prevent
> > > the implicit conversion).
> > >
> > > The attached patch solves the rich_location problem by a) making
> > > the ctor explicit, b) disabling the rich_location copy ctor, c)
> > > changing the parser to use direct initialization. (I CC Jason
> > > as a heads up on the C++ FE bits.)
> >
> > The C++ bits are fine.
> >
> > > The semi_embedded_vec should be fixed as well, regardless of this
> > > particular use and patch. Let me know if it's okay to commit
> > > (I'm
> > > not open to disabling its copy ctor).
> >
> > > + /* Not copyable or assignable. */
> >
> > This comment needs a rationale.
>
> Done in the attached patch.
LGTM; thanks
Dave
>
> Providing a rationale in each instance sounds like a good addition
> to the coding conventions. Let me propose a patch for that.
>
> Martin
next prev parent reply other threads:[~2021-06-16 18:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 1:48 Martin Sebor
2021-06-16 12:38 ` David Malcolm
2021-06-16 14:52 ` Martin Sebor
2021-06-16 15:06 ` David Malcolm
2021-06-16 16:11 ` Martin Sebor
2021-06-16 16:35 ` Jason Merrill
2021-06-16 17:21 ` Martin Sebor
2021-06-16 18:50 ` David Malcolm [this message]
2021-06-22 20:59 ` [PING][PATCH] " Martin Sebor
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=5c4ca226721bb05eb9403fc154755ae8e6243e71.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=msebor@gmail.com \
/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).