I find that in memcpy, if the size = 0, the program will still copy one byte to destination. Why?
#include <iostream>
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_functions.h"
using namespace std;
__global__ void copy(char *dev)
{
char temp = 'g';
memcpy(dev + 10,&temp,0);
}
int main( )
{
char *host = new char [32];
char *host1 = new char [32];
char *dev;
host = "abbbbbbbbbbbbbbbbbbbbbbbbbbb";
cudaError error1 = cudaMalloc(&dev,32);
cudaError error2 = cudaMemcpy(dev,host,32,cudaMemcpyHostToDevice);
copy<<<1,1>>>(dev);
cudaError error3 = cudaMemcpy(host1,dev,32,cudaMemcpyDeviceToHost);
cout<<host1<<endl;
return 0;
}