public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57716] New: std::thread does not compile with vector<int>& as argument
@ 2013-06-25 21:45 felix-gcc at fefe dot de
  2013-06-26  7:26 ` [Bug libstdc++/57716] " schwab@linux-m68k.org
  0 siblings, 1 reply; 2+ messages in thread
From: felix-gcc at fefe dot de @ 2013-06-25 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57716
           Summary: std::thread does not compile with vector<int>& as
                    argument
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix-gcc at fefe dot de

When trying out the std::thread support in g++ 4.8.1, I tried this test
program:

#include <thread>
#include <vector>

using namespace std;

void thethread(vector<int>& b) {
  // do something
}

int main() {
  vector<int> x { 1,2,3 };
  thethread(x); // works
  thread foo(thethread,x);      // compiler error
  foo.join();
}

calling the thread directly works, but doing it via the thread initialization
fails with this error message:

In file included from /usr/include/c++/4.8.1/thread:39:0,
                 from t.cc:1:
/usr/include/c++/4.8.1/functional: In instantiation of ‘struct
std::_Bind_simple<void (*(std::vector<int>))(std::vector<int>&)>’:
/usr/include/c++/4.8.1/thread:137:47:   required from
‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void
(&)(std::vector<int>&); _Args = {std::vector<int, std::allocator<int> >&}]’
t.cc:13:25:   required from here
/usr/include/c++/4.8.1/functional:1697:61: error: no type named ‘type’ in
‘class std::result_of<void (*(std::vector<int>))(std::vector<int>&)>’
       typedef typename result_of<_Callable(_Args...)>::type result_type;
                                                             ^
/usr/include/c++/4.8.1/functional:1727:9: error: no type named ‘type’ in ‘class
std::result_of<void (*(std::vector<int>))(std::vector<int>&)>’
         _M_invoke(_Index_tuple<_Indices...>)
         ^

I also tried 4.8.0, same issue.  A fried tried this with g++ 4.6.3 and it
worked there, so it appears to be a regression.  Or maybe Ubuntu fixed
something in their branch of g++.  I'm using stock gcc, the friend tried the
gcc from Ubuntu 12.04.

Note that the issue goes away if I change the function to take a pointer
instead of a reference to a vector<int>.
>From gcc-bugs-return-425140-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 25 21:58:31 2013
Return-Path: <gcc-bugs-return-425140-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1311 invoked by alias); 25 Jun 2013 21:58:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 1274 invoked by uid 48); 25 Jun 2013 21:58:25 -0000
From: "felix-gcc at fefe dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/57716] std::thread does not compile with vector<int>& as argument
Date: Tue, 25 Jun 2013 21:58:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: felix-gcc at fefe dot de
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-57716-4-P8P0Vn2qug@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57716-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57716-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg01519.txt.bz2
Content-length: 533

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW716

felix-gcc at fefe dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from felix-gcc at fefe dot de ---
Never mind, this appears to be by design.

http://stackoverflow.com/questions/15235885/invalid-initialization-of-non-const-reference-with-c11-thread


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

* [Bug libstdc++/57716] std::thread does not compile with vector<int>& as argument
  2013-06-25 21:45 [Bug libstdc++/57716] New: std::thread does not compile with vector<int>& as argument felix-gcc at fefe dot de
@ 2013-06-26  7:26 ` schwab@linux-m68k.org
  0 siblings, 0 replies; 2+ messages in thread
From: schwab@linux-m68k.org @ 2013-06-26  7:26 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |INVALID


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

end of thread, other threads:[~2013-06-26  7:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-25 21:45 [Bug libstdc++/57716] New: std::thread does not compile with vector<int>& as argument felix-gcc at fefe dot de
2013-06-26  7:26 ` [Bug libstdc++/57716] " schwab@linux-m68k.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).