public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial
@ 2021-05-29  5:47 rs2740 at gmail dot com
  2021-06-17 12:30 ` [Bug libstdc++/100823] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: rs2740 at gmail dot com @ 2021-05-29  5:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100823
           Summary: Special member functions of common_iterator should be
                    conditionally trivial
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

At least as a QoI matter, the special member functions of common_iterator<I, S>
should be trivial when the corresponding special member function of variant<I,
S> is. Given that the standard depicts a variant<I, S> exposition-only member
with implicitly declared special member functions, it is arguable that this is
actually required.

There appears to be a couple other conformance issues too:

- the move special members are missing
- the copy assignment calls the converting assignment operator, but unlike the
latter, there's no !valueless_by_exception() precondition on the (implicitly
declared) copy assignment.

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
@ 2021-06-17 12:30 ` redi at gcc dot gnu.org
  2021-06-29 19:14 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-17 12:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-06-17

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
  2021-06-17 12:30 ` [Bug libstdc++/100823] " redi at gcc dot gnu.org
@ 2021-06-29 19:14 ` redi at gcc dot gnu.org
  2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-29 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

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] 11+ messages in thread

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
  2021-06-17 12:30 ` [Bug libstdc++/100823] " redi at gcc dot gnu.org
  2021-06-29 19:14 ` redi at gcc dot gnu.org
@ 2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
  2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-20 22:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 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:56c999860bbbb2fd5091ba0985e2e5eaa90c6478

commit r13-1770-g56c999860bbbb2fd5091ba0985e2e5eaa90c6478
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator assignment [PR100823]

    This fixes the following conformance problems reported in the PR:

    - Move constructor and move assignment should be defined.
    - Copy assignment from a valueless object should be allowed.

    Assignment is completely rewritten by this patch, as the previous
    version had a number of problems. The converting assignment failed to
    handle the case of assigning a new value to a valueless object, which
    should work. It only accepted lvalue arguments, so wasn't usable to
    implement the move assignment operator. Finally, it enforced the
    precondition that the argument is not valueless, which is correct for
    the converting assignment but not for the copy assignment.

    A new _M_assign member is added to handle all cases of assignment
    (copying from an lvalue, moving from an rvalue, and converting from a
    different type). The not valueless precondition is checked in the
    converting assignment before calling _M_assign, so isn't enforced for
    copy and move assignment. The new function no longer uses a switch, so
    handles valueless objects as the LHS or RHS of the assignment.

    libstdc++-v3/ChangeLog:

            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define move
            constructor and move assignment operator.
            (common_iterator::_M_assign): New function implementing
            assignment.
            (common_iterator::operator=): Use _M_assign.
            (common_iterator::_S_valueless): New constant.
            * testsuite/24_iterators/common_iterator/100823.cc: New test.

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
@ 2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
  2022-07-20 23:01 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-20 22:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:87a9bfe86d8a87d09de5d60e430d14bfa6c816f0

commit r13-1771-g87a9bfe86d8a87d09de5d60e430d14bfa6c816f0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator triviality [PR100823]

    This fixes the remaining problem reported in the PR, that the special
    members should be trivial.  This can be done by constraining the
    non-trivial versions and adding defaulted overloads that will be used
    when the union members are trivial.

    Making these members trivial alters the argument passing ABI and so
    isn't suitable for backporting to release branches.

    libstdc++-v3/ChangeLog:

            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define
            destructor, copy constructor and move constructor as trivial
            when the underlying types allow.
            * testsuite/24_iterators/common_iterator/100823.cc: Check
            triviality of special members.

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
@ 2022-07-20 23:01 ` redi at gcc dot gnu.org
  2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-20 23:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far. I plan to backport the r13-1770 commit (but not the one
changing triviality).

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-07-20 23:01 ` redi at gcc dot gnu.org
@ 2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
  2022-07-22  7:08 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 11:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:06443fa2d467ec3180cc2c287f71cc0fc2c16840

commit r12-8597-g06443fa2d467ec3180cc2c287f71cc0fc2c16840
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator assignment [PR100823]

    This fixes the following conformance problems reported in the PR:

    - Move constructor and move assignment should be defined.
    - Copy assignment from a valueless object should be allowed.

    Assignment is completely rewritten by this patch, as the previous
    version had a number of problems. The converting assignment failed to
    handle the case of assigning a new value to a valueless object, which
    should work. It only accepted lvalue arguments, so wasn't usable to
    implement the move assignment operator. Finally, it enforced the
    precondition that the argument is not valueless, which is correct for
    the converting assignment but not for the copy assignment.

    A new _M_assign member is added to handle all cases of assignment
    (copying from an lvalue, moving from an rvalue, and converting from a
    different type). The not valueless precondition is checked in the
    converting assignment before calling _M_assign, so isn't enforced for
    copy and move assignment. The new function no longer uses a switch, so
    handles valueless objects as the LHS or RHS of the assignment.

    libstdc++-v3/ChangeLog:

            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define move
            constructor and move assignment operator.
            (common_iterator::_M_assign): New function implementing
            assignment.
            (common_iterator::operator=): Use _M_assign.
            (common_iterator::_S_valueless): New constant.
            * testsuite/24_iterators/common_iterator/100823.cc: New test.

    (cherry picked from commit 56c999860bbbb2fd5091ba0985e2e5eaa90c6478)

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
@ 2022-07-22  7:08 ` cvs-commit at gcc dot gnu.org
  2022-07-22  7:10 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-22  7:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:7cfef93a241e89f7e019cd1048808aa8e8c07836

commit r11-10166-g7cfef93a241e89f7e019cd1048808aa8e8c07836
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator assignment [PR100823]

    This fixes the following conformance problems reported in the PR:

    - Move constructor and move assignment should be defined.
    - Copy assignment from a valueless object should be allowed.

    Assignment is completely rewritten by this patch, as the previous
    version had a number of problems. The converting assignment failed to
    handle the case of assigning a new value to a valueless object, which
    should work. It only accepted lvalue arguments, so wasn't usable to
    implement the move assignment operator. Finally, it enforced the
    precondition that the argument is not valueless, which is correct for
    the converting assignment but not for the copy assignment.

    A new _M_assign member is added to handle all cases of assignment
    (copying from an lvalue, moving from an rvalue, and converting from a
    different type). The not valueless precondition is checked in the
    converting assignment before calling _M_assign, so isn't enforced for
    copy and move assignment. The new function no longer uses a switch, so
    handles valueless objects as the LHS or RHS of the assignment.

    libstdc++-v3/ChangeLog:

            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define move
            constructor and move assignment operator.
            (common_iterator::_M_assign): New function implementing
            assignment.
            (common_iterator::operator=): Use _M_assign.
            (common_iterator::_S_valueless): New constant.
            * testsuite/24_iterators/common_iterator/100823.cc: New test.

    (cherry picked from commit 56c999860bbbb2fd5091ba0985e2e5eaa90c6478)

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-07-22  7:08 ` cvs-commit at gcc dot gnu.org
@ 2022-07-22  7:10 ` redi at gcc dot gnu.org
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  2023-04-27 23:06 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-22  7:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The triviality of special members is only fixed for GCC 13, but the other
conformance bugs are fixed for 11.4 and 12.2

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-07-22  7:10 ` redi at gcc dot gnu.org
@ 2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  2023-04-27 23:06 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:5d7de4c8fd9af68011e1fa7bc1d022db81d89594

commit r10-11317-g5d7de4c8fd9af68011e1fa7bc1d022db81d89594
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator assignment [PR100823]

    This fixes the following conformance problems reported in the PR:

    - Move constructor and move assignment should be defined.
    - Copy assignment from a valueless object should be allowed.

    Assignment is completely rewritten by this patch, as the previous
    version had a number of problems. The converting assignment failed to
    handle the case of assigning a new value to a valueless object, which
    should work. It only accepted lvalue arguments, so wasn't usable to
    implement the move assignment operator. Finally, it enforced the
    precondition that the argument is not valueless, which is correct for
    the converting assignment but not for the copy assignment.

    A new _M_assign member is added to handle all cases of assignment
    (copying from an lvalue, moving from an rvalue, and converting from a
    different type). The not valueless precondition is checked in the
    converting assignment before calling _M_assign, so isn't enforced for
    copy and move assignment. The new function no longer uses a switch, so
    handles valueless objects as the LHS or RHS of the assignment.

    libstdc++-v3/ChangeLog:

            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define move
            constructor and move assignment operator.
            (common_iterator::_M_assign): New function implementing
            assignment.
            (common_iterator::operator=): Use _M_assign.
            (common_iterator::_S_valueless): New constant.
            * testsuite/24_iterators/common_iterator/100823.cc: New test.

    (cherry picked from commit 56c999860bbbb2fd5091ba0985e2e5eaa90c6478)

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

* [Bug libstdc++/100823] Special member functions of common_iterator should be conditionally trivial
  2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
                   ` (8 preceding siblings ...)
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
@ 2023-04-27 23:06 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-27 23:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> The triviality of special members is only fixed for GCC 13, but the other
> conformance bugs are fixed for 11.4 and 12.2

And 10.5 too.

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

end of thread, other threads:[~2023-04-27 23:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-29  5:47 [Bug libstdc++/100823] New: Special member functions of common_iterator should be conditionally trivial rs2740 at gmail dot com
2021-06-17 12:30 ` [Bug libstdc++/100823] " redi at gcc dot gnu.org
2021-06-29 19:14 ` redi at gcc dot gnu.org
2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
2022-07-20 23:01 ` redi at gcc dot gnu.org
2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
2022-07-22  7:08 ` cvs-commit at gcc dot gnu.org
2022-07-22  7:10 ` redi at gcc dot gnu.org
2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
2023-04-27 23:06 ` 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).