Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Compile error with concurrent priority and moveinsertable element

Pierre_S_
Beginner
305 Views

Hi,

When i used moveinsertable element but noncopyable element with concurrent priority_queue, i have a compilation error:

g++ -o test_tbb -std=c++11 -ltbb test_tbb.cpp 
In file included from /usr/include/tbb/concurrent_priority_queue.h:25:0,
                 from test_tbb.cpp:2:
/usr/include/tbb/cache_aligned_allocator.h: In instantiation of ‘void tbb::cache_aligned_allocator<T>::construct(U*, Args&& ...) [with U = event; Args = {const event&}; T = event]’:
/usr/include/c++/4.9/bits/alloc_traits.h:253:4:   required from ‘static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = event; _Args = {const event&}; _Alloc = tbb::cache_aligned_allocator<event>; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]’
/usr/include/c++/4.9/bits/alloc_traits.h:399:57:   required from ‘static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = event; _Args = {const event&}; _Alloc = tbb::cache_aligned_allocator<event>; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]’
/usr/include/c++/4.9/bits/stl_vector.h:918:34:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = event; _Alloc = tbb::cache_aligned_allocator<event>; std::vector<_Tp, _Alloc>::value_type = event]’
/usr/include/tbb/concurrent_priority_queue.h:366:25:   required from ‘void tbb::interface5::concurrent_priority_queue<T, Compare, A>::handle_operations(tbb::interface5::concurrent_priority_queue<T, Compare, A>::cpq_operation*) [with T = event; Compare = event_comp; A = tbb::cache_aligned_allocator<event>]’
/usr/include/tbb/concurrent_priority_queue.h:294:13:   required from ‘void tbb::interface5::concurrent_priority_queue<T, Compare, A>::my_functor_t::operator()(tbb::interface5::concurrent_priority_queue<T, Compare, A>::cpq_operation*) [with T = event; Compare = event_comp; A = tbb::cache_aligned_allocator<event>]’
/usr/include/tbb/internal/_aggregator_impl.h:136:34:   required from ‘void tbb::interface6::internal::aggregator_generic<operation_type>::start_handle_operations(handler_type&) [with handler_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::my_functor_t; operation_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::cpq_operation]’
/usr/include/tbb/internal/_aggregator_impl.h:88:54:   required from ‘void tbb::interface6::internal::aggregator_generic<operation_type>::execute(operation_type*, handler_type&, bool) [with handler_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::my_functor_t; operation_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::cpq_operation]’
/usr/include/tbb/internal/_aggregator_impl.h:153:74:   required from ‘void tbb::interface6::internal::aggregator<handler_type, operation_type>::execute(operation_type*) [with handler_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::my_functor_t; operation_type = tbb::interface5::concurrent_priority_queue<event, event_comp>::cpq_operation]’
/usr/include/tbb/concurrent_priority_queue.h:224:9:   required from ‘void tbb::interface5::concurrent_priority_queue<T, Compare, A>::push(tbb::interface5::concurrent_priority_queue<T, Compare, A>::value_type&&) [with T = event; Compare = event_comp; A = tbb::cache_aligned_allocator<event>; tbb::interface5::concurrent_priority_queue<T, Compare, A>::value_type = event]’                                                                                                        
test_tbb.cpp:33:32:   required from here                                                                                                                                                                                                     
/usr/include/tbb/cache_aligned_allocator.h:100:11: error: use of deleted function ‘event::event(const event&)’                                                                                                                               
         { ::new((void *)p) U(std::forward<Args>(args)...); }                                                                                                                                                                                
           ^                                                                                                                                                                                                                                 
test_tbb.cpp:13:2: note: declared here                                                                                                                                                                                                       
  event(const event& ) = delete;

If i made copy constructor with failed assert, my program work fine but it's bad.

 

On Debian Jessie (Linux 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux) with gcc 4.9.1

 

0 Kudos
3 Replies
Alexei_K_Intel
Employee
305 Views

Hi Pierre,

We reproduced the compilation error. There is an issue in tbb::concurrent_priority_queue that it requires a copy constructor even it is not called. Thank you for the report.

As for work-around you have already suggested it that it is possible to define a stub for copy constructor which really will not be called if you do not call coping push_back.

0 Kudos
Pierre_S_
Beginner
305 Views

Thank for your answer

0 Kudos
Alexey-Kukanov
Employee
305 Views

The problem should be fixed in 4.3 Update 2.

0 Kudos
Reply