From: Richard Sandiford <richard.sandiford@linaro.org>
To: Trevor Saunders <tbsaunde@tbsaunde.org>
Cc: Richard Biener <richard.guenther@gmail.com>,
tbsaunde+gcc@tbsaunde.org,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 05/13] allow constructing a auto_vec with a preallocation, and a possibly larger actual allocation size
Date: Thu, 11 May 2017 09:04:00 -0000 [thread overview]
Message-ID: <87o9uzrd9x.fsf@linaro.org> (raw)
In-Reply-To: <20170511081817.phelh2tt657qfqqv@ball> (Trevor Saunders's message of "Thu, 11 May 2017 04:18:17 -0400")
Trevor Saunders <tbsaunde@tbsaunde.org> writes:
> On Thu, May 11, 2017 at 10:01:51AM +0200, Richard Biener wrote:
>> On Thu, May 11, 2017 at 9:45 AM, Trevor Saunders
>> <tbsaunde@tbsaunde.org> wrote:
>> > On Wed, May 10, 2017 at 07:54:13AM +0100, Richard Sandiford wrote:
>> >> tbsaunde+gcc@tbsaunde.org writes:
>> >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>> >> >
>> >> > This allows us to set the capacity of the vector when we construct it,
>> >> > and still use a stack buffer when the size is small enough.
>> >> >
>> >> > gcc/ChangeLog:
>> >> >
>> >> > 2017-05-09 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>> >> >
>> >> > * genrecog.c (int_set::int_set): Explicitly construct our
>> >> > auto_vec base class.
>> >> > * vec.h (auto_vec::auto_vec): New constructor.
>> >> > ---
>> >> > gcc/genrecog.c | 8 +++++---
>> >> > gcc/vec.h | 12 ++++++++++++
>> >> > 2 files changed, 17 insertions(+), 3 deletions(-)
>> >> >
>> >> > diff --git a/gcc/genrecog.c b/gcc/genrecog.c
>> >> > index 6a9e610e7a0..b69043f0d02 100644
>> >> > --- a/gcc/genrecog.c
>> >> > +++ b/gcc/genrecog.c
>> >> > @@ -1407,14 +1407,16 @@ struct int_set : public auto_vec <uint64_t, 1>
>> >> > iterator end ();
>> >> > };
>> >> >
>> >> > -int_set::int_set () {}
>> >> > +int_set::int_set () : auto_vec<uint64_t, 1> () {}
>> >> >
>> >> > -int_set::int_set (uint64_t label)
>> >> > +int_set::int_set (uint64_t label) :
>> >> > + auto_vec<uint64_t, 1> ()
>> >> > {
>> >> > safe_push (label);
>> >> > }
>> >> >
>> >> > -int_set::int_set (const int_set &other)
>> >> > +int_set::int_set (const int_set &other) :
>> >> > + auto_vec<uint64_t, 1> ()
>> >> > {
>> >> > safe_splice (other);
>> >> > }
>> >>
>> >> Is this part of the patch necessary? Won't the default constructor
>> >> be used anyway?
>> >
>> > Well, without the change to the copy constructor we get this bootstrap
>> > warning.
>> >
>> > /src/gcc/gcc/genrecog.c: In copy constructor ‘int_set::int_set(const int_set&)’:
>> > /src/gcc/gcc/genrecog.c:1417:1: error: base class ‘class auto_vec<long
>> > unsigned int, 1>’ should be explicitly initialized in the copy
>> > constructor [-Werror=extra]
>> > int_set::int_set (const int_set &other)
>> > ^~~~~~~
>> >
>> >>
>> > So we need to do something about that. I'm not sure the other cases are
>> > necessary, but I was there, and being explicit seemed better than
>> > leaving it implicit.
>>
>> Ah,
>>
>> /* If these initializations are taking place in a copy constructor,
>> the base class should probably be explicitly initialized if there
>> is a user-defined constructor in the base class (other than the
>> default constructor, which will be called anyway). */
>> if (extra_warnings
>> && DECL_COPY_CONSTRUCTOR_P (current_function_decl)
>> && type_has_user_nondefault_constructor (BINFO_TYPE (subobject)))
>> warning_at (DECL_SOURCE_LOCATION (current_function_decl),
>> OPT_Wextra, "base class %q#T should be explicitly "
>> "initialized in the copy constructor",
>> BINFO_TYPE (subobject));
>>
>> ok - fine then. Probably could be avoided with
>>
>> auto_vec() = defaulted;
>>
>> (or how you'd write that)
>
> Well, we don't get to use = default in C++98, so we'd have to ifdef, I
> guess it could work since it would fix the warning outside of stage 1,
> but seems pretty gross.
Yeah. OK for the genrecog.c bit.
Thanks,
Richard
next prev parent reply other threads:[~2017-05-11 8:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 20:53 [PATCH 00/13] misc data structure stuff tbsaunde+gcc
2017-05-09 20:53 ` [PATCH 04/13] allow auto_bitmap to use other bitmap obstacks tbsaunde+gcc
2017-05-10 8:27 ` Richard Biener
2017-05-09 20:53 ` [PATCH 09/13] use auto_bitmap more with alternate obstacks tbsaunde+gcc
2017-05-10 8:31 ` Richard Biener
2017-05-09 20:53 ` [PATCH 13/13] make inverted_post_order_compute() operate on a vec tbsaunde+gcc
2017-05-10 8:44 ` Richard Biener
2017-05-09 20:53 ` [PATCH 08/13] move several bitmaps from gc memory to the default obstack and use auto_bitmap tbsaunde+gcc
2017-05-10 8:26 ` Richard Biener
2017-05-09 20:53 ` [PATCH 10/13] make a member an auto_sbitmap tbsaunde+gcc
2017-05-10 8:26 ` Richard Biener
2017-05-09 20:53 ` [PATCH 07/13] use auto_bitmap more tbsaunde+gcc
2017-05-10 8:28 ` Richard Biener
2017-05-09 20:53 ` [PATCH 06/13] replace some manual stacks with auto_vec tbsaunde+gcc
2017-05-10 8:26 ` Richard Biener
2017-05-09 20:53 ` [PATCH 05/13] allow constructing a auto_vec with a preallocation, and a possibly larger actual allocation size tbsaunde+gcc
2017-05-10 6:58 ` Richard Sandiford
2017-05-11 7:50 ` Trevor Saunders
2017-05-11 8:18 ` Richard Biener
2017-05-11 8:23 ` Trevor Saunders
2017-05-11 9:04 ` Richard Sandiford [this message]
2017-05-09 20:53 ` [PATCH 02/13] improve bitmap / sbitmap compatability of bitmap_set_bit tbsaunde+gcc
2017-05-10 6:54 ` Richard Sandiford
2017-05-11 8:01 ` Trevor Saunders
2017-05-09 20:53 ` [PATCH 03/13] store the bitmap_head within the auto_bitmap tbsaunde+gcc
2017-05-10 8:25 ` Richard Biener
2017-05-09 20:53 ` [PATCH 01/13] improve safety of freeing bitmaps tbsaunde+gcc
2017-05-10 8:15 ` Richard Biener
2017-05-10 10:55 ` Trevor Saunders
2017-05-10 11:11 ` Richard Biener
2017-05-09 20:53 ` [PATCH 12/13] make depth_first_search_ds a class tbsaunde+gcc
2017-05-10 8:29 ` Richard Biener
2017-05-09 20:55 ` [PATCH 11/13] make more vars auto_sbitmaps tbsaunde+gcc
2017-05-10 8:27 ` Richard Biener
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=87o9uzrd9x.fsf@linaro.org \
--to=richard.sandiford@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=tbsaunde+gcc@tbsaunde.org \
--cc=tbsaunde@tbsaunde.org \
/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).