- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
I was trying to get a hello world c++11 program going, but it seems like the non-gcc compilers don't like it very much. I am probably doing something wrong, but I can't figure out what. Here is the simple hello world program, along with how I am compiling it. Both, clang and intel complained about it. I just included clang for completeness.
--------------------- hw.cpp ------------------
#include <thread>
#include <iostream>
int main()
{
auto hello_world = [] () { std::cout << "Hello world" << std::endl; };
std::thread thr(hello_world);
thr.join();
return 0;
}
$ g++ -std=c++11 hw.cpp -lpthread && ./a.out
Hello world
$ clang++ -std=libc++ -std=c++11 hw.cpp -lpthread && ./a.out
pure virtual method called
terminate called without an active exception
Aborted (core dumped)
(here are the paths that the intel compiler is using)
$ icpc -std=c++11 -v -x c++ /dev/null -fsyntax-only
icpc version 13.0.1 (gcc version 4.7.0 compatibility)
/opt/intel/composer_xe_2013.1.117/bin/intel64/mcpcom -_g -mP3OPT_inline_alloca -D__HONOR_STD -D__ICC=1300 -D__INTEL_COMPILER=1300 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__INTEL_CXX11_MODE__ -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__NO_INLINE__ -D__GNUC_GNU_INLINE__ -D__STRICT_ANSI__ -D__GXX_EXPERIMENTAL_CXX0X__ -D__GNUG__=4 -D__GNUC__=4 -D__GNUC_MINOR__=7 -D__GNUC_PATCHLEVEL__=0 -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1002 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D_MT -D__INTEL_COMPILER_BUILD_DATE=20121010 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE__ -D__MMX__ -_k -_8 -_l -_a -_b -n --gnu_version=470 -_W5 --gcc-extern-inline -p --bool -tused -mGLOB_eh_linux -x --c++0x --multibyte_chars --array_section --simd --simd_func --offload_mode=1 --offload_target_names=mic,MIC --bool -mP1OPT_print_version=FALSE -mP1OPT_version=13.0-intel64 -mGLOB_diag_file=null.diag /dev/null
#include "..." search starts here:
#include <...> search starts here:
/opt/intel/composer_xe_2013.1.117/compiler/include/intel64
/opt/intel/composer_xe_2013.1.117/compiler/include
/usr/include/c++/4.7
/usr/include/c++/4.7/x86_64-linux-gnu
/usr/include/c++/4.7/backward
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.7/include
/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
/usr/include
/usr/include/x86_64-linux-gnu
End of search list.
$ icpc -std=c++11 hw.cpp -lpthread && ./a.out
/usr/include/c++/4.7/type_traits(1048): error: function "lambda []()->void::operator=(const lambda []()->void &)" (declared at line 6 of "hw.cpp") cannot be referenced -- it is a deleted function
static decltype(declval<_Tp1>() = declval<_Up1>(), __one())
^
detected during:
instantiation of class "std::__is_assignable_helper<_Tp, _Up> [with _Tp=lambda []()->void &, _Up=lambda []()->void &&]" at line 1062
instantiation of class "std::is_assignable<_Tp, _Up> [with _Tp=lambda []()->void &, _Up=lambda []()->void &&]" at line 117
instantiation of class "std::__and_<_B1, _B2> [with _B1=std::is_assignable<lambda []()->void &, lambda []()->void &&>, _B2=std::__is_nt_assignable_impl<lambda []()->void &, lambda []()->void &&>]" at line 1110
instantiation of class "std::is_nothrow_assignable<_Tp, _Up> [with _Tp=lambda []()->void &, _Up=lambda []()->void &&]" at line 1140
instantiation of class "std::__is_nt_move_assignable_impl<_Tp, false> [with _Tp=lambda []()->void]" at line 1146
[ 2 instantiation contexts not shown ]
instantiation of class "std::_Tuple_impl<_Idx, _Head, _Tail...> [with _Idx=0UL, _Head=lambda []()->void, _Tail=<>]" at line 374 of "/usr/include/c++/4.7/tuple"
instantiation of class "std::tuple<_Elements...> [with _Elements=<lambda []()->void>]" at line 1601 of "/usr/include/c++/4.7/functional"
instantiation of class "std::_Bind_simple<_Callable (_Args...)> [with _Callable=lambda []()->void, _Args=<>]" at line 1619 of "/usr/include/c++/4.7/functional"
instantiation of "std::_Bind_simple_helper<_Callable, _Args...>::__type std::__bind_simple(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 135 of "/usr/include/c++/4.7/thread"
instantiation of "std::thread::thread(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 8 of "hw.cpp"
/usr/include/c++/4.7/type_traits(1103): error: function "lambda []()->void::operator=(const lambda []()->void &)" (declared at line 6 of "hw.cpp") cannot be referenced -- it is a deleted function
: public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
^
detected during:
instantiation of class "std::__is_nt_assignable_impl<_Tp, _Up> [with _Tp=lambda []()->void &, _Up=lambda []()->void &&]" at line 117
instantiation of class "std::__and_<_B1, _B2> [with _B1=std::is_assignable<lambda []()->void &, lambda []()->void &&>, _B2=std::__is_nt_assignable_impl<lambda []()->void &, lambda []()->void &&>]" at line 1110
instantiation of class "std::is_nothrow_assignable<_Tp, _Up> [with _Tp=lambda []()->void &, _Up=lambda []()->void &&]" at line 1140
instantiation of class "std::__is_nt_move_assignable_impl<_Tp, false> [with _Tp=lambda []()->void]" at line 1146
instantiation of class "std::is_nothrow_move_assignable<_Tp> [with _Tp=lambda []()->void]" at line 117
instantiation of class "std::__and_<_B1, _B2> [with _B1=std::is_nothrow_move_assignable<lambda []()->void>, _B2=std::is_nothrow_move_assignable<std::_Tuple_impl<1UL>>]" at line 332 of "/usr/include/c++/4.7/tuple"
instantiation of class "std::_Tuple_impl<_Idx, _Head, _Tail...> [with _Idx=0UL, _Head=lambda []()->void, _Tail=<>]" at line 374 of "/usr/include/c++/4.7/tuple"
instantiation of class "std::tuple<_Elements...> [with _Elements=<lambda []()->void>]" at line 1601 of "/usr/include/c++/4.7/functional"
instantiation of class "std::_Bind_simple<_Callable (_Args...)> [with _Callable=lambda []()->void, _Args=<>]" at line 1619 of "/usr/include/c++/4.7/functional"
instantiation of "std::_Bind_simple_helper<_Callable, _Args...>::__type std::__bind_simple(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 135 of "/usr/include/c++/4.7/thread"
instantiation of "std::thread::thread(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 8 of "hw.cpp"
/usr/include/c++/4.7/bits/alloc_traits.h(56): error: expression must have a constant value
static const bool __value = _S_chk<_Alloc, _Tp>(nullptr);
^
detected during:
instantiation of class "std::__alloctr_rebind_helper<_Alloc, _Tp> [with _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Tp=std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>]" at line 63
processing of template argument list for "std::__alloctr_rebind" based on template arguments <std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>> at line 201
instantiation of type "std::allocator_traits<_Alloc>::rebind_alloc<std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>> [with _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>]" at line 203
instantiation of type "std::allocator_traits<_Alloc>::rebind_traits<std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>> [with _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>]" at line 520 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp *, const _Alloc &, _Args &&...) [with _Lp=__gnu_cxx::_S_atomic, _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 998 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Lp=__gnu_cxx::_S_atomic, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 318 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 599 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::allocate_shared<_Tp,_Alloc,_Args...>(const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 615 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::make_shared<_Tp,_Args...>(_Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 191 of "/usr/include/c++/4.7/thread"
instantiation of "std::shared_ptr<std::thread::_Impl<_Callable>> std::thread::_M_make_routine(_Callable &&) [with _Callable=std::_Bind_simple<lambda []()->void ()>]" at line 135 of "/usr/include/c++/4.7/thread"
instantiation of "std::thread::thread(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 8 of "hw.cpp"
/usr/include/c++/4.7/bits/alloc_traits.h(201): error: incomplete type is not allowed
using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;
^
detected during:
instantiation of type "std::allocator_traits<_Alloc>::rebind_alloc<std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>> [with _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>]" at line 203
instantiation of type "std::allocator_traits<_Alloc>::rebind_traits<std::_Sp_counted_ptr_inplace<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, __gnu_cxx::_S_atomic>> [with _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>]" at line 520 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp *, const _Alloc &, _Args &&...) [with _Lp=__gnu_cxx::_S_atomic, _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 998 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Lp=__gnu_cxx::_S_atomic, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 318 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 599 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::allocate_shared<_Tp,_Alloc,_Args...>(const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 615 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::make_shared<_Tp,_Args...>(_Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 191 of "/usr/include/c++/4.7/thread"
instantiation of "std::shared_ptr<std::thread::_Impl<_Callable>> std::thread::_M_make_routine(_Callable &&) [with _Callable=std::_Bind_simple<lambda []()->void ()>]" at line 135 of "/usr/include/c++/4.7/thread"
instantiation of "std::thread::thread(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 8 of "hw.cpp"
/usr/include/c++/4.7/bits/alloc_traits.h(89): error: name followed by "::" must be a class or namespace name
typedef typename _Alloc::value_type value_type;
^
detected during:
instantiation of class "std::allocator_traits<_Alloc> [with _Alloc=<error-type>]" at line 521 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp *, const _Alloc &, _Args &&...) [with _Lp=__gnu_cxx::_S_atomic, _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 998 of "/usr/include/c++/4.7/bits/shared_ptr_base.h"
instantiation of "std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Lp=__gnu_cxx::_S_atomic, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 318 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 599 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::allocate_shared<_Tp,_Alloc,_Args...>(const _Alloc &, _Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Alloc=std::allocator<std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 615 of "/usr/include/c++/4.7/bits/shared_ptr.h"
instantiation of "std::shared_ptr<_Tp> std::make_shared<_Tp,_Args...>(_Args &&...) [with _Tp=std::thread::_Impl<std::_Bind_simple<lambda []()->void ()>>, _Args=<std::_Bind_simple<lambda []()->void ()>>]" at line 191 of "/usr/include/c++/4.7/thread"
instantiation of "std::shared_ptr<std::thread::_Impl<_Callable>> std::thread::_M_make_routine(_Callable &&) [with _Callable=std::_Bind_simple<lambda []()->void ()>]" at line 135 of "/usr/include/c++/4.7/thread"
instantiation of "std::thread::thread(_Callable &&, _Args &&...) [with _Callable=lambda []()->void &, _Args=<>]" at line 8 of "hw.cpp"
compilation aborted for hw.cpp (code 2)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for fixing this in the new release! It works as expected now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hw.cpp compiles fine in the newest update.
$ icpc -v
icpc version 13.1.3 (gcc version 4.7.0 compatibility)
$ icpc --version
icpc (ICC) 13.1.3 20130607
Copyright (C) 1985-2013 Intel Corporation. All rights reserved.
$ gcc --version
gcc (Gentoo 4.7.3 p1.0, pie-0.5.5) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ icpc -std=c++11 -lpthread -o hw hw.cpp
$ ./hw
Hello world
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank, yes this is fixed (thought I'd responded apparently not registered here)
Regards.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page