Thrust::sort error with rdc and extended-lambda nvcc flag in visual studio

I found that when I enabled the -rdc=true and --extended-lambda options simultaneously, the following test code:

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <iostream>

void print(const thrust::device_vector<int>& v)
{
    for (size_t i = 0; i < v.size(); i++)
        std::cout << " " << v[i];
    std::cout << "\n";
}

int main()
{
    thrust::device_vector<int> vec(10, 1);
    thrust::device_vector<int> index(10, 1);

    const int* event_ptr = thrust::raw_pointer_cast(vec.data());

    auto comp = [event_ptr] __device__(int a, int b) {
        return event_ptr[a] < event_ptr[b];
    };

    print(index);
    thrust::sort(index.begin(), index.end(), comp);
    print(index);

    return 0;
}

would report an error:

CUDA error 700 [C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\include\cub/util_device.cuh, 512]: an illegal memory access was encountered

with Visual Studio C++ Runtime Library Error:

Debug Error!
Program: E:\2F\github\cuda test\x64\Debug\thrust_sort_rdc.exe
abortO has been called
(Press Retry to debug the application)

But it can operate normally after the rdc is turned off. I’m not sure why this is so, but the rdc option is necessary for my project. Is there a solution?