public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type
@ 2014-01-18 11:17 potswa at mac dot com
  2014-01-18 12:42 ` [Bug libstdc++/59872] " potswa at mac dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-18 11:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

            Bug ID: 59872
           Summary: Cannot move std::map with move-only mapped_type
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: potswa at mac dot com

This fails because the std::map move constructor apparently invokes a copy
operation. It was working recently (on trunk), so it looks like a regression.


#include <map>
#include <memory>

std::map< int, std::unique_ptr< int > > q, r( std::move( q ) );


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

* [Bug libstdc++/59872] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
@ 2014-01-18 12:42 ` potswa at mac dot com
  2014-01-18 13:22 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-18 12:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #1 from David Krauss <potswa at mac dot com> ---
It looks like the allocator-aware update introduced a copying branch to the
move constructor, to handle the case of transferring an object from one
stateful allocator to another.

The branch on _Alloc_traits::_S_always_equal(), presumably a constant value,
should be split into two functions. I'll continue digging in, I don't yet
understand _Alloc_trats or why _S_always_equal is a private interface.


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

* [Bug libstdc++/59872] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
  2014-01-18 12:42 ` [Bug libstdc++/59872] " potswa at mac dot com
@ 2014-01-18 13:22 ` redi at gcc dot gnu.org
  2014-01-18 13:32 ` potswa at mac dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-18 13:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, the branch that copies needs to be a separate function.

http://cplusplus.github.io/LWG/lwg-active.html#2108 might answer your last
question


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

* [Bug libstdc++/59872] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
  2014-01-18 12:42 ` [Bug libstdc++/59872] " potswa at mac dot com
  2014-01-18 13:22 ` redi at gcc dot gnu.org
@ 2014-01-18 13:32 ` potswa at mac dot com
  2014-01-18 14:54 ` potswa at mac dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-18 13:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #3 from David Krauss <potswa at mac dot com> ---
Thanks, I'm working on it now.

Is there some precedent for this kind of SFINAE in libstdc++? The hard part is
getting the style right. Metaprogramming looks weird in 80 columns.

As for the defect report, my thoughts exactly. Maybe we can extend
__allocator_always_compares_equal to evaluate such an equality check in a
SFINAE, constant expression context. Then a user-defined

constexpr bool operator == ( my_alloc, my_alloc )
    { return true; }

will satisfy the condition, but anything else will default.


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

* [Bug libstdc++/59872] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (2 preceding siblings ...)
  2014-01-18 13:32 ` potswa at mac dot com
@ 2014-01-18 14:54 ` potswa at mac dot com
  2014-01-18 14:56 ` potswa at mac dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-18 14:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #4 from David Krauss <potswa at mac dot com> ---
Created attachment 31884
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31884&action=edit
SFINAE based fix

This seems stylistically OK, but I did copy-paste the implementation of moving.
Perhaps the common code should be factored into a new function, or the
constructor should simply call into move assignment.

It fixes the problem but I was unable to run the testsuite. This is a brand-new
installation and I haven't used it for contribution yet. (It says "WARNING:
could not find `runtest'".)


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

* [Bug libstdc++/59872] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (3 preceding siblings ...)
  2014-01-18 14:54 ` potswa at mac dot com
@ 2014-01-18 14:56 ` potswa at mac dot com
  2014-01-19 12:50 ` [Bug libstdc++/59872] [4.9 Regression] " redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-18 14:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

David Krauss <potswa at mac dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #31884|0                           |1
        is obsolete|                            |

--- Comment #5 from David Krauss <potswa at mac dot com> ---
Created attachment 31885
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31885&action=edit
SFINAE based fix


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

* [Bug libstdc++/59872] [4.9 Regression] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (4 preceding siblings ...)
  2014-01-18 14:56 ` potswa at mac dot com
@ 2014-01-19 12:50 ` redi at gcc dot gnu.org
  2014-01-19 12:51 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-19 12:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-01-19
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Target Milestone|---                         |4.9.0
            Summary|Cannot move std::map with   |[4.9 Regression] Cannot
                   |move-only mapped_type       |move std::map with
                   |                            |move-only mapped_type
     Ever confirmed|0                           |1


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

* [Bug libstdc++/59872] [4.9 Regression] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (5 preceding siblings ...)
  2014-01-19 12:50 ` [Bug libstdc++/59872] [4.9 Regression] " redi at gcc dot gnu.org
@ 2014-01-19 12:51 ` redi at gcc dot gnu.org
  2014-01-19 12:55 ` potswa at mac dot com
  2014-01-23 17:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-19 12:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't want to use SFINAE here, I'll fix it the same way it's done in the
other containers, tag dispatching using
  std::integral_constant<bool, _Alloc_Traits::_S_always_Equal()>


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

* [Bug libstdc++/59872] [4.9 Regression] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (6 preceding siblings ...)
  2014-01-19 12:51 ` redi at gcc dot gnu.org
@ 2014-01-19 12:55 ` potswa at mac dot com
  2014-01-23 17:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: potswa at mac dot com @ 2014-01-19 12:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

--- Comment #7 from David Krauss <potswa at mac dot com> ---
That's a better factoring. I was just avoiding creating a new, named function.
Thanks!


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

* [Bug libstdc++/59872] [4.9 Regression] Cannot move std::map with move-only mapped_type
  2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
                   ` (7 preceding siblings ...)
  2014-01-19 12:55 ` potswa at mac dot com
@ 2014-01-23 17:34 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-23 17:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59872

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
fixed


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

end of thread, other threads:[~2014-01-23 17:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-18 11:17 [Bug libstdc++/59872] New: Cannot move std::map with move-only mapped_type potswa at mac dot com
2014-01-18 12:42 ` [Bug libstdc++/59872] " potswa at mac dot com
2014-01-18 13:22 ` redi at gcc dot gnu.org
2014-01-18 13:32 ` potswa at mac dot com
2014-01-18 14:54 ` potswa at mac dot com
2014-01-18 14:56 ` potswa at mac dot com
2014-01-19 12:50 ` [Bug libstdc++/59872] [4.9 Regression] " redi at gcc dot gnu.org
2014-01-19 12:51 ` redi at gcc dot gnu.org
2014-01-19 12:55 ` potswa at mac dot com
2014-01-23 17:34 ` 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).