Error while using cublasIcamax with device pointer to store the result

Got the access violation while running the following code
cudaError_t cudaStat ;
cublasStatus_t stat ;
cublasHandle_t handle ;
stat = cublasCreate(&handle) ;
if (stat != CUBLAS_STATUS_SUCCESS)
{
printf (“CUBLAS initialization failed\n”) ;
return 0;
}
int dev;
int host = 0;
const int N = 128;
cudaMalloc((void
*)&dev, sizeof(int));
cublasSetVector(1, sizeof(int),&host, 1, dev, 1);
cuComplex devPtr;
cudaMalloc((void
*)&devPtr, sizeof(cuComplex)N);
cuComplex data[N];
for(int i= 0 ; i < N ; i++)
{
data[i].x = static_cast(sin(0.049125
i));
data[i].y = static_cast (0.0);
}
cudaMemcpy(devPtr, data , sizeof(cuComplex)*N, cudaMemcpyHostToDevice);
stat = cublasIcamax_v2(handle, N,devPtr,1,dev);
if (stat != CUBLAS_STATUS_SUCCESS)
{
printf (“Find max element failed\n”) ;
return 0;
}
This code work fine if I pass host vector to store the result of cublasIcamax.
e.g
int res = 0;
stat = cublasIcamax_v2(handle, N,devPtr,1,&res);
if (stat != CUBLAS_STATUS_SUCCESS)
{
printf (“Find max element failed\n”) ;
return 0;
}

Could anyone help with it?