public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
@ 2014-03-18 12:46 ralph.tandetzky at gmail dot com
  2014-03-18 13:11 ` [Bug libstdc++/60564] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ralph.tandetzky at gmail dot com @ 2014-03-18 12:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60564
           Summary: [C++11] The std::packaged_task constructor taking a
                    reference to a functor does not copy its argument.
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ralph.tandetzky at gmail dot com

The following code compiles successfully:

~~~~~~~~~~~~~~~~~~~~~
#include <future>
#include <iostream>

using namespace std;

struct Test
{
    Test()               { cout << "constructed." << endl; }
    Test( const Test & ) { cout << "copied."      << endl; }
    Test( Test && )      { cout << "moved."       << endl; }
    void operator()() const {}
};

int main()
{
    Test t;
    packaged_task<void()> pt1( t );
}
~~~~~~~~~~~~~~~~~~~~~

It produces the following output:

~~~~~~~~~~~~~~~~~~~~~
constructed.
moved.
~~~~~~~~~~~~~~~~~~~~~

However, the constructor of std::packaged_task<void()> should copy it's
argument into its internally stored task object according to 30.6.9.1 of the
C++11 standard (I'm referring to N3485, actually). 

Settings: I've used the online-compiler of http://en.cppreference.com/ with the
compiler GCC 4.8 (C++11). GCC 4.7 (C++11) does not have the bug, but produces a
correct output copying the object passed into the constructor.


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

* [Bug libstdc++/60564] [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
  2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
@ 2014-03-18 13:11 ` redi at gcc dot gnu.org
  2014-03-18 13:17 ` [Bug libstdc++/60564] [4.8/4.9 Regression] " redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-18 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-03-18
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oops, yes, it uses std::move when it should be std::forward


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

* [Bug libstdc++/60564] [4.8/4.9 Regression] [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
  2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
  2014-03-18 13:11 ` [Bug libstdc++/60564] " redi at gcc dot gnu.org
@ 2014-03-18 13:17 ` redi at gcc dot gnu.org
  2014-03-18 16:31 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-18 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.3
            Summary|[C++11] The                 |[4.8/4.9 Regression]
                   |std::packaged_task          |[C++11] The
                   |constructor taking a        |std::packaged_task
                   |reference to a functor does |constructor taking a
                   |not copy its argument.      |reference to a functor does
                   |                            |not copy its argument.

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I caused a regression with http://gcc.gnu.org/r196695


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

* [Bug libstdc++/60564] [4.8/4.9 Regression] [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
  2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
  2014-03-18 13:11 ` [Bug libstdc++/60564] " redi at gcc dot gnu.org
  2014-03-18 13:17 ` [Bug libstdc++/60564] [4.8/4.9 Regression] " redi at gcc dot gnu.org
@ 2014-03-18 16:31 ` redi at gcc dot gnu.org
  2014-03-18 16:32 ` redi at gcc dot gnu.org
  2014-03-18 16:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-18 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Mar 18 16:30:28 2014
New Revision: 208655

URL: http://gcc.gnu.org/viewcvs?rev=208655&root=gcc&view=rev
Log:
    PR libstdc++/60564
    * include/std/future (__future_base::_Task_state<>): Change
    constructors to template functions using perfect forwarding.
    (__create_task_state): Use decayed type as stored task.
    (packaged_task::packaged_task(_Fn&&)): Forward instead of moving.
    * testsuite/30_threads/packaged_task/60564.cc: New.

Added:
   
branches/gcc-4_8-branch/libstdc++-v3/testsuite/30_threads/packaged_task/60564.cc
Modified:
    branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_8-branch/libstdc++-v3/include/std/future


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

* [Bug libstdc++/60564] [4.8/4.9 Regression] [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
  2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
                   ` (2 preceding siblings ...)
  2014-03-18 16:31 ` redi at gcc dot gnu.org
@ 2014-03-18 16:32 ` redi at gcc dot gnu.org
  2014-03-18 16:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-18 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Mar 18 16:31:38 2014
New Revision: 208656

URL: http://gcc.gnu.org/viewcvs?rev=208656&root=gcc&view=rev
Log:
    PR libstdc++/60564
    * include/std/future (__future_base::_Task_state<>): Change
    constructors to template functions using perfect forwarding.
    (__create_task_state): Use decayed type as stored task.
    (packaged_task::packaged_task(_Fn&&)): Forward instead of moving.
    * testsuite/30_threads/packaged_task/60564.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/30_threads/packaged_task/60564.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/future


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

* [Bug libstdc++/60564] [4.8/4.9 Regression] [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument.
  2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
                   ` (3 preceding siblings ...)
  2014-03-18 16:32 ` redi at gcc dot gnu.org
@ 2014-03-18 16:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-18 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.7.4
         Resolution|---                         |FIXED
      Known to fail|                            |4.8.2

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on the trunk and branch, thanks for reporting it.


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

end of thread, other threads:[~2014-03-18 16:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-18 12:46 [Bug libstdc++/60564] New: [C++11] The std::packaged_task constructor taking a reference to a functor does not copy its argument ralph.tandetzky at gmail dot com
2014-03-18 13:11 ` [Bug libstdc++/60564] " redi at gcc dot gnu.org
2014-03-18 13:17 ` [Bug libstdc++/60564] [4.8/4.9 Regression] " redi at gcc dot gnu.org
2014-03-18 16:31 ` redi at gcc dot gnu.org
2014-03-18 16:32 ` redi at gcc dot gnu.org
2014-03-18 16:33 ` 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).