public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v4] libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]
Date: Tue, 16 Jan 2024 15:39:12 +0000	[thread overview]
Message-ID: <CACb0b4nV9GOjOOXNrXwWebw+2zxqS1DDguAgYLvdmP8gYid9OQ@mail.gmail.com> (raw)
In-Reply-To: <ZaaNfgr8IuHDy4F5@zen.kayari.org>

On Tue, 16 Jan 2024 at 14:07, Jonathan Wakely wrote:
>
> On 15/01/24 19:09 -0500, Patrick Palka wrote:
> >> +    friend _Iterator
> >> +    operator+(_Iterator __i, difference_type __n)
> >
> >constexpr?
>
> Fixed. I've added tests that all iterator ops are usable in constant
> expressions, which found a bug in operator+= (it didn't let you
> increment one past the end of the range).

I found another bug in operator+= which is fixed and tested like so:

--- a/libstdc++-v3/include/std/text_encoding
+++ b/libstdc++-v3/include/std/text_encoding
@@ -584,7 +584,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
               *this == _Iterator{};
           }
       }
-      __glibcxx_assert(_M_rep != nullptr);
+      if (__n != 0)
+       __glibcxx_assert(_M_rep != nullptr);
      return *this;
    }

--- a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
+++ b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
@@ -67,6 +67,11 @@ test_constexpr_iterator()
  VERIFY( *(iter + 1) == iter[1] );
  VERIFY( (1 + iter - 1) == begin );
  VERIFY( (-1 + (iter - -2) + -1) == begin );
+
+  std::ranges::iterator_t<std::text_encoding::aliases_view> singular;
+  VERIFY( (singular + 0) == singular );
+  VERIFY( (singular - 0) == singular );
+
  return true;
}
static_assert( test_constexpr_iterator() );


  reply	other threads:[~2024-01-16 15:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 22:29 [WIP] libstdc++: Implement C++26 std::text_encoding [PR113318] Jonathan Wakely
2024-01-13 12:44 ` [PATCH v2] " Jonathan Wakely
2024-01-15 20:45   ` [PATCH v3] libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] Jonathan Wakely
2024-01-15 22:24     ` Ulrich Drepper
2024-01-16  0:09     ` Patrick Palka
2024-01-16 14:06       ` [PATCH v4] " Jonathan Wakely
2024-01-16 15:39         ` Jonathan Wakely [this message]
2024-01-16 16:17           ` Jonathan Wakely
2024-01-17 12:14             ` [committed v5] " Jonathan Wakely

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=CACb0b4nV9GOjOOXNrXwWebw+2zxqS1DDguAgYLvdmP8gYid9OQ@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.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).