public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability
@ 2022-07-09  3:40 dan.raviv at gmail dot com
  2022-07-09  5:49 ` [Bug libstdc++/106239] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dan.raviv at gmail dot com @ 2022-07-09  3:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106239
           Summary: vector::resize(size_type, const value_type&) should
                    not require copy-assignability
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dan.raviv at gmail dot com
  Target Milestone: ---

Copy-constructibility should be enough.
Related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83981

https://godbolt.org/z/a1sYxThxG
Compiles on Clang but not GCC:

#include <vector>

class C {
    const int m_x;
public:
    C(int x) : m_x (x) {}
};

int main()
{
    auto v = std::vector<C>(10, C(42));
    // v.resize(11);     //   Correctly does not compile
    v.resize(11, C(42)); // Incorrectly does not compile on GCC
}

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
@ 2022-07-09  5:49 ` pinskia at gcc dot gnu.org
  2022-07-09  5:54 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-09  5:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm:
https://en.cppreference.com/w/cpp/container/vector/resize (I know exactly not
the C++ standard but usually gives a good summary of it):
-T must meet the requirements of CopyInsertable in order to use overload (2).

https://en.cppreference.com/w/cpp/named_req/CopyInsertable
https://en.cppreference.com/w/cpp/named_req/MoveInsertable



I think libstdc++ is correct here ...

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
  2022-07-09  5:49 ` [Bug libstdc++/106239] " pinskia at gcc dot gnu.org
@ 2022-07-09  5:54 ` pinskia at gcc dot gnu.org
  2022-07-09 11:13 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-09  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://cplusplus.github.io/LWG/issue2033

Officially made it CopyInsertable:

Requires: T shall be MoveInsertable into *this and CopyInsertable into *this.

CopyInsertable is basically:
::new((void*)p) T(v)
 (for pre c++20).

So yes it would be invalid.

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
  2022-07-09  5:49 ` [Bug libstdc++/106239] " pinskia at gcc dot gnu.org
  2022-07-09  5:54 ` pinskia at gcc dot gnu.org
@ 2022-07-09 11:13 ` redi at gcc dot gnu.org
  2022-07-09 17:03 ` dan.raviv at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-09 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2022-07-09

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> https://cplusplus.github.io/LWG/issue2033

Yes, I think we're missing the resolution to that issue.

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
                   ` (2 preceding siblings ...)
  2022-07-09 11:13 ` redi at gcc dot gnu.org
@ 2022-07-09 17:03 ` dan.raviv at gmail dot com
  2023-02-08 11:27 ` redi at gcc dot gnu.org
  2023-02-16 12:53 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dan.raviv at gmail dot com @ 2022-07-09 17:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dan Raviv <dan.raviv at gmail dot com> ---
C does meet the CopyInsertible requirements:

https://godbolt.org/z/8j7KcbhdM

#include <memory>

class C {
    const int m_x;
public:
    C(int x) : m_x (x) {}
};

int main()
{
    // C is CopyInsertable:
    {
        alignas(C) char mem[sizeof(C)];
        auto v = C(42);
        C* c = ::new((void*)mem) C(v);
        c->~C();
    }
    {
        alignas(C) char mem[sizeof(C)];
        auto v = C(42);
        C* c = std::construct_at ((C*)mem, v);
        c->~C();
    }
}

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
                   ` (3 preceding siblings ...)
  2022-07-09 17:03 ` dan.raviv at gmail dot com
@ 2023-02-08 11:27 ` redi at gcc dot gnu.org
  2023-02-16 12:53 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-08 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Dup of PR 90192 and PR 83981

*** This bug has been marked as a duplicate of bug 83981 ***

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

* [Bug libstdc++/106239] vector::resize(size_type, const value_type&) should not require copy-assignability
  2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
                   ` (4 preceding siblings ...)
  2023-02-08 11:27 ` redi at gcc dot gnu.org
@ 2023-02-16 12:53 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-16 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marc.mutz at hotmail dot com

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 108820 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-02-16 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09  3:40 [Bug libstdc++/106239] New: vector::resize(size_type, const value_type&) should not require copy-assignability dan.raviv at gmail dot com
2022-07-09  5:49 ` [Bug libstdc++/106239] " pinskia at gcc dot gnu.org
2022-07-09  5:54 ` pinskia at gcc dot gnu.org
2022-07-09 11:13 ` redi at gcc dot gnu.org
2022-07-09 17:03 ` dan.raviv at gmail dot com
2023-02-08 11:27 ` redi at gcc dot gnu.org
2023-02-16 12: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).