public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Fix bug in iterator_traits<common_iterator<S,I>>
Date: Fri, 07 Feb 2020 16:58:00 -0000	[thread overview]
Message-ID: <20200207165835.GA1107662@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

The wrong type was being used in the __common_iter_has_arrow constraint,
creating a circular dependency where the iterator_traits specialization
was needed before it was complete. The correct parameter for the
__common_iter_has_arrow concept is the first template argument of  the
common_iterator, not the common_iterator itself.

	* include/bits/stl_iterator.h (__detail::__common_iter_ptr): Change
	to take parameters of common_iterator, instead of the common_iterator
	type itself. Fix argument for __common_iter_has_arrow constraint.
	(iterator_traits<common_iterator<I, S>>::pointer): Adjust.

Tested powerpc64le-linux, committed to master.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2420 bytes --]

commit d222d8ec3c100f5c0a6974e7dcee16903f6f0e3a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Feb 7 16:46:42 2020 +0000

    libstdc++: Fix bug in iterator_traits<common_iterator<S,I>>
    
    The wrong type was being used in the __common_iter_has_arrow constraint,
    creating a circular dependency where the iterator_traits specialization
    was needed before it was complete. The correct parameter for the
    __common_iter_has_arrow concept is the first template argument of  the
    common_iterator, not the common_iterator itself.
    
            * include/bits/stl_iterator.h (__detail::__common_iter_ptr): Change
            to take parameters of common_iterator, instead of the common_iterator
            type itself. Fix argument for __common_iter_has_arrow constraint.
            (iterator_traits<common_iterator<I, S>>::pointer): Adjust.

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 69c6ae66cdf..46804656801 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1738,17 +1738,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   namespace __detail
   {
     // FIXME: This has to be at namespace-scope because of PR 92103.
-    template<typename _Iter>
+    template<typename _It, typename _Sent>
       struct __common_iter_ptr
       {
 	using type = void;
       };
 
-    template<typename _Iter>
-      requires __detail::__common_iter_has_arrow<_Iter>
-      struct __common_iter_ptr<_Iter>
+    template<typename _It, typename _Sent>
+      requires __detail::__common_iter_has_arrow<_It>
+      struct __common_iter_ptr<_It, _Sent>
       {
-	using type = decltype(std::declval<const _Iter&>().operator->());
+	using common_iterator = std::common_iterator<_It, _Sent>;
+
+	using type
+	  = decltype(std::declval<const common_iterator&>().operator->());
       };
   } // namespace __detail
 
@@ -1762,8 +1765,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	forward_iterator_tag, input_iterator_tag>;
       using value_type = iter_value_t<_It>;
       using difference_type = iter_difference_t<_It>;
-      using pointer = typename
-	__detail::__common_iter_ptr<common_iterator<_It, _Sent>>::type;
+      using pointer = typename __detail::__common_iter_ptr<_It, _Sent>::type;
       using reference = iter_reference_t<_It>;
     };
 

                 reply	other threads:[~2020-02-07 16:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200207165835.GA1107662@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).