You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<oneapi/tbb.h>
#include<oneapi/tbb/concurrent_queue.h>classA
{
public:A(int a, int b) { }
};
intmain(){
oneapi::tbb::concurrent_queue<A> q1;
}
Compiler output
g++ -I repos/oneTBB/include -L repos/oneTBB/build/gnu_11.2_cxx11_64_relwithdebinfo main.cpp -ltbb -o main
In file included from repos/oneTBB/include/oneapi/tbb.h:42,
from main.cpp:1:
repos/oneTBB/include/oneapi/tbb/concurrent_queue.h: In instantiation of ‘void tbb::detail::d2::concurrent_queue<T, Allocator>::clear() [with T = A; Allocator = tbb::detail::d1::cache_aligned_allocator<A>]’:
repos/oneTBB/include/oneapi/tbb/concurrent_queue.h:111:9: required from ‘tbb::detail::d2::concurrent_queue<T, Allocator>::~concurrent_queue() [with T = A; Allocator = tbb::detail::d1::cache_aligned_allocator<A>]’
main.cpp:11:38: required from here
repos/oneTBB/include/oneapi/tbb/concurrent_queue.h:152:15: error: no matching function for call to ‘A::A()’
152 | T value;
| ^~~~~
main.cpp:7:5: note: candidate: ‘A::A(int, int)’
7 | A(int a, int b) { }
| ^
main.cpp:7:5: note: candidate expects 2 arguments, 0 provided
main.cpp:4:7: note: candidate: ‘constexpr A::A(const A&)’
4 | class A
| ^
main.cpp:4:7: note: candidate expects 1 argument, 0 provided
main.cpp:4:7: note: candidate: ‘constexpr A::A(A&&)’
main.cpp:4:7: note: candidate expects 1 argument, 0 provided
make: *** [Makefile:5: all] Error 1
The problem is cause by the function clear of concurrent_queue (oneTBB/include/oneapi/tbb/concurrent_queue.h:152) that instantiates an object to to be popped and clear the queue.
booltry_pop( T& result ) {
returninternal_try_pop(&result);
}
voidclear() {
while (!empty()) {
T value;
try_pop(value);
}
}
Is it possible to use void* so that we can use concurrent_queue in these cases?
@VitorRamos, thank you for reporting the issue and proposing the solution.
Unfortunately, it would not work because it results in undefined behavior - call to malloc only allocates the memory for value and then it would be assigned inside of internal_try_pop. It results in assigning the value that was not created by the constructor call.
We also cannot explicitly call the constructor because we do not know which constructors are available and would not want to require any.
I have made a quick fix in PR #886 that explicitly informs the internal_try_pop that the value popped should not be assigned . It should fix the issue.
@VitorRamos, I have just merged the fix into oneTBB master.
Feel free to re-open the issue or create a separate one if it does not satisfy your use case.
The problem:
Compiler output
The problem is cause by the function clear of concurrent_queue (oneTBB/include/oneapi/tbb/concurrent_queue.h:152) that instantiates an object to to be popped and clear the queue.
Is it possible to use void* so that we can use concurrent_queue in these cases?
If that is ok, I can submit a PR.
The text was updated successfully, but these errors were encountered: