Skip to content

Commit 56ff462

Browse files
committed
Device-side thrust::count_if lambda should capture by value
Previous capture by reference would be an invalid memory access across a kernel launch.
1 parent 6a21183 commit 56ff462

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

c++11_cuda/c++11_cuda.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void xyzw_frequency_thrust_device(int *count, char *text, int n)
5555
{
5656
const char letters[] { 'x','y','z','w' };
5757

58-
*count = thrust::count_if(thrust::device, text, text+n, [&](char c) {
58+
*count = thrust::count_if(thrust::device, text, text+n, [=](char c) {
5959
for (const auto x : letters)
6060
if (c == x) return true;
6161
return false;

0 commit comments

Comments
 (0)