johnsonjh / duma

duma: Detect Unintended Memory Access (D.U.M.A.) - A Red-Zone memory allocator
https://github.com/johnsonjh/duma
GNU General Public License v2.0
99 stars 10 forks source link

error C2036: “const void *”: unknown size in pointer arithmetic #183

Open rsp4jack opened 2 years ago

rsp4jack commented 2 years ago

In src/duma.c line 2254:

    void *_duma_memmove(void *dest, const void *src, size_t size) {
      char *d = (char *)dest;
      const char *s = (const char *)src;

      if (d < s) {
     --> const char *end = src + size;

In MSVC, it will raise an error:

error C2036: “const void *”: unknown size

Because the compiler needs to know the size of the data it points to do the pointer arithmetic.

Note:

int* p = 0x0; // Just for example
p += 1;
// p is 0x4 now

char* cp = 0x0;
cp += 1;
// cp is 0x1 now

So, change this line to:

const char *end = (const char*) src + size;
johnsonjh commented 2 years ago

Thanks, I'll try to get this in this weekend and investigate your other issue.