public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented
@ 2022-02-08 17:40 de34 at live dot cn
  2022-02-08 17:48 ` [Bug libstdc++/104443] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: de34 at live dot cn @ 2022-02-08 17:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

            Bug ID: 104443
           Summary: common_iterator<I, S>::operator-> is not correctly
                    implemented
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

When the adapted iterator type I is a pointer type or has operator->,
std::common_iterator<I, S>::operator-> is required to return the iterator by
reference ([common.iter.access]/(5.1), and std::get for std::variant always
returns reference).

However, currently libstdc++'s implementation returns the iterator by value in
these cases, because "return _M_it;" is used and the return type is specified
by decltype(auto). "return (_M_it);" should be used instead.

Currently only libc++ correctly implements both common_iterator<I,
S>::operator-> and iterator_traits<common_iterator<I, S>>::pointer. See
https://gcc.godbolt.org/z/1Tn5cGrhh.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
@ 2022-02-08 17:48 ` redi at gcc dot gnu.org
  2022-02-09 16:08 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-08 17:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-02-08

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
  2022-02-08 17:48 ` [Bug libstdc++/104443] " redi at gcc dot gnu.org
@ 2022-02-09 16:08 ` redi at gcc dot gnu.org
  2022-02-09 20:49 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-09 16:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
  2022-02-08 17:48 ` [Bug libstdc++/104443] " redi at gcc dot gnu.org
  2022-02-09 16:08 ` redi at gcc dot gnu.org
@ 2022-02-09 20:49 ` redi at gcc dot gnu.org
  2022-02-12 11:52 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-09 20:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
On further reflection, I'm not convinced the standard really intends to make
the pointer type a reference. That's weird. Returning a pointer as a pointer
makes a lot more sense.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (2 preceding siblings ...)
  2022-02-09 20:49 ` redi at gcc dot gnu.org
@ 2022-02-12 11:52 ` redi at gcc dot gnu.org
  2022-07-28 10:55 ` de34 at live dot cn
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-12 11:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |SUSPENDED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've submitted an LWG issue to change the standard, as returning a raw pointer
by reference is silly.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (3 preceding siblings ...)
  2022-02-12 11:52 ` redi at gcc dot gnu.org
@ 2022-07-28 10:55 ` de34 at live dot cn
  2022-07-29  9:11 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: de34 at live dot cn @ 2022-07-28 10:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

--- Comment #3 from Jiang An <de34 at live dot cn> ---
LWG3672 has been adopted, so no change is needed and this issue can be closed.
Although it might be more clear to use auto instead of decltype(auto).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (4 preceding siblings ...)
  2022-07-28 10:55 ` de34 at live dot cn
@ 2022-07-29  9:11 ` cvs-commit at gcc dot gnu.org
  2022-07-29  9:12 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-29  9:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:b5f5d1b36edbcd7d923f2e2653e54e52637c715b

commit r13-1890-gb5f5d1b36edbcd7d923f2e2653e54e52637c715b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 28 20:55:51 2022 +0100

    libstdc++: Tweak common_iterator::operator-> return type [PR104443]

    This adjusts the return type to match the resolution of LWG 3672. There
    is no functional difference, because decltype(auto) always deduced a
    value anyway, but this makes it simpler and consistent with the working
    draft.

    libstdc++-v3/ChangeLog:

            PR libstdc++/104443
            * include/bits/stl_iterator.h (common_iterator::operator->):
            Change return type to just auto.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (5 preceding siblings ...)
  2022-07-29  9:11 ` cvs-commit at gcc dot gnu.org
@ 2022-07-29  9:12 ` redi at gcc dot gnu.org
  2022-08-03 13:47 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-29  9:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|SUSPENDED                   |RESOLVED
   Target Milestone|---                         |13.0

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jiang An from comment #3)
> LWG3672 has been adopted, so no change is needed and this issue can be
> closed. Although it might be more clear to use auto instead of
> decltype(auto).

Agreed, and done. Thanks for the report and update.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (6 preceding siblings ...)
  2022-07-29  9:12 ` redi at gcc dot gnu.org
@ 2022-08-03 13:47 ` cvs-commit at gcc dot gnu.org
  2022-08-03 13:49 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-03 13:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:1a9681e60964c7f7ce0892e14745e6dcf6100157

commit r12-8660-g1a9681e60964c7f7ce0892e14745e6dcf6100157
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 28 20:55:51 2022 +0100

    libstdc++: Tweak common_iterator::operator-> return type [PR104443]

    This adjusts the return type to match the resolution of LWG 3672. There
    is no functional difference, because decltype(auto) always deduced a
    value anyway, but this makes it simpler and consistent with the working
    draft.

    libstdc++-v3/ChangeLog:

            PR libstdc++/104443
            * include/bits/stl_iterator.h (common_iterator::operator->):
            Change return type to just auto.

    (cherry picked from commit b5f5d1b36edbcd7d923f2e2653e54e52637c715b)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (7 preceding siblings ...)
  2022-08-03 13:47 ` cvs-commit at gcc dot gnu.org
@ 2022-08-03 13:49 ` redi at gcc dot gnu.org
  2022-09-07 17:49 ` cvs-commit at gcc dot gnu.org
  2022-09-07 17:53 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-08-03 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |12.2

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Backported for 12.2

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (8 preceding siblings ...)
  2022-08-03 13:49 ` redi at gcc dot gnu.org
@ 2022-09-07 17:49 ` cvs-commit at gcc dot gnu.org
  2022-09-07 17:53 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-07 17:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:c5038b792525fedeb0297189516d0157ba98c1d1

commit r11-10240-gc5038b792525fedeb0297189516d0157ba98c1d1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 28 20:55:51 2022 +0100

    libstdc++: Tweak common_iterator::operator-> return type [PR104443]

    This adjusts the return type to match the resolution of LWG 3672. There
    is no functional difference, because decltype(auto) always deduced a
    value anyway, but this makes it simpler and consistent with the working
    draft.

    libstdc++-v3/ChangeLog:

            PR libstdc++/104443
            * include/bits/stl_iterator.h (common_iterator::operator->):
            Change return type to just auto.

    (cherry picked from commit b5f5d1b36edbcd7d923f2e2653e54e52637c715b)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/104443] common_iterator<I, S>::operator-> is not correctly implemented
  2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
                   ` (9 preceding siblings ...)
  2022-09-07 17:49 ` cvs-commit at gcc dot gnu.org
@ 2022-09-07 17:53 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-07 17:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.2                        |11.4

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And for 11.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-09-07 17:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 17:40 [Bug libstdc++/104443] New: common_iterator<I, S>::operator-> is not correctly implemented de34 at live dot cn
2022-02-08 17:48 ` [Bug libstdc++/104443] " redi at gcc dot gnu.org
2022-02-09 16:08 ` redi at gcc dot gnu.org
2022-02-09 20:49 ` redi at gcc dot gnu.org
2022-02-12 11:52 ` redi at gcc dot gnu.org
2022-07-28 10:55 ` de34 at live dot cn
2022-07-29  9:11 ` cvs-commit at gcc dot gnu.org
2022-07-29  9:12 ` redi at gcc dot gnu.org
2022-08-03 13:47 ` cvs-commit at gcc dot gnu.org
2022-08-03 13:49 ` redi at gcc dot gnu.org
2022-09-07 17:49 ` cvs-commit at gcc dot gnu.org
2022-09-07 17:53 ` redi at gcc dot gnu.org

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).