public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Josh Marshall <joshua.r.marshall.1991@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>, libstdc++@gcc.gnu.org
Subject: Re: Should reinterpret_cast be constexpr?
Date: Mon, 28 Dec 2020 20:19:47 -0500	[thread overview]
Message-ID: <CAFkJGRcAqHjrk+y-T1F8rHRUPkcDvCPZW5JhVi0qpP2btj1NGA@mail.gmail.com> (raw)
In-Reply-To: <CAFkJGRem_HFTtj93pyWVpvMtjSDLBU8u9nUVXshOTovsEjDaHw@mail.gmail.com>

I think it is time for a check in.  I have two tests failing, one related
to the code your snippet tries to fix and another which looks like a bug in
swapping elements.

https://gitlab.com/anadon/gcc

The lines of interest are
libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_element.cc:67
(bug)
libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_element.cc:130
(bug)
libstdc++-v3/testsuite/23_containers/vector/constexpr/function_insert.cc:35
(needs implementation)

Those are what I see as the current problems.  Now might also be the time
to start examining the rest of the work.  There's no way I kept to coding
standards when I'm this new.


On Mon, Dec 28, 2020 at 4:53 PM Josh Marshall <
joshua.r.marshall.1991@gmail.com> wrote:

> OK.  Thanks for the freebie :)
>
> On Mon, Dec 28, 2020 at 4:25 PM Jonathan Wakely <jwakely.gcc@gmail.com>
> wrote:
>
>> On Mon, 28 Dec 2020 at 20:50, Josh Marshall
>> <joshua.r.marshall.1991@gmail.com> wrote:
>> >
>> > Is this in master?  If so, I'll just merge it in.
>>
>> No, I just made a local change and haven't even committed it locally.
>>
>>
>> >
>> > On Mon, Dec 28, 2020 at 3:47 PM Jonathan Wakely <jwakely.gcc@gmail.com>
>> wrote:
>> >>
>> >> On Mon, 28 Dec 2020 at 20:33, Jonathan Wakely <jwakely.gcc@gmail.com>
>> wrote:
>> >> >
>> >> > On Mon, 28 Dec 2020 at 19:51, Josh Marshall via Libstdc++
>> >> > <libstdc++@gcc.gnu.org> wrote:
>> >> > >
>> >> > > Hello all,
>> >> > >
>> >> > > From the test error `libstdc++-v3/include/bits/stl_vector.h:1837:
>> error:
>> >> > > 'reinterpret_cast' is not a constant expression` and the
>> documentation at
>> >> > > https://en.cppreference.com/w/cpp/language/reinterpret_cast , is
>> >> > > `reinterpret_cast()` not constexpr in error?
>> >> >
>> >> > No, it's not an error. reinterpret_cast is not allowed in constant
>> expressions.
>> >>
>> >> This patch replaces the use of reinterpret_cast with an alternative
>> >> using C++20 features:
>> >>
>> >> diff --git a/libstdc++-v3/include/bits/vector.tcc
>> >> b/libstdc++-v3/include/bits/vector.tcc
>> >> index 27e63388feb..93b2ccc02e3 100644
>> >> --- a/libstdc++-v3/include/bits/vector.tcc
>> >> +++ b/libstdc++-v3/include/bits/vector.tcc
>> >> @@ -516,9 +516,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
>> >>            {
>> >> #if __cplusplus < 201103L
>> >>              value_type __x_copy = __x;
>> >> -#else
>> >> +#elif ! __cpp_lib_make_obj_using_allocator
>> >>              _Temporary_value __tmp(this, __x);
>> >>              value_type& __x_copy = __tmp._M_val();
>> >> +#else
>> >> +             value_type __x_copy = std::make_from_tuple<value_type>(
>> >> +                 std::uses_allocator_construction_args<value_type>(
>> >> +                   _M_get_Tp_allocator(), __x));
>> >> #endif
>> >>              const size_type __elems_after = end() - __position;
>> >>              pointer __old_finish(this->_M_impl._M_finish);
>>
>

      parent reply	other threads:[~2020-12-29  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-28 19:51 Josh Marshall
2020-12-28 20:33 ` Jonathan Wakely
2020-12-28 20:47   ` Jonathan Wakely
2020-12-28 20:49     ` Josh Marshall
2020-12-28 21:24       ` Jonathan Wakely
     [not found]         ` <CAFkJGRem_HFTtj93pyWVpvMtjSDLBU8u9nUVXshOTovsEjDaHw@mail.gmail.com>
2020-12-29  1:19           ` Josh Marshall [this message]

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=CAFkJGRcAqHjrk+y-T1F8rHRUPkcDvCPZW5JhVi0qpP2btj1NGA@mail.gmail.com \
    --to=joshua.r.marshall.1991@gmail.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=libstdc++@gcc.gnu.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).