Andy Lester <a...@petdance.com> added the comment:

Casting tail to (void *)tail was the correct thing to do.  The problem is that 
casting to void* casts away the constness of tail.  The even more correct thing 
to do is what my patch does, which is cast it to (const void *)tail.

There is no functional difference between sending a const void * and a void * 
to fprintf.  However, it's one more bit of noise for -Wcast-qual to gripe 
about.  My hope is to clear up the noise to find the real problems.

For example, if you had this very bad code:

    const char *msg = "literal";
    strcpy(msg, "another string");

then the compiler would complain you're passing a non-const char * to the first 
arg of strcpy that wants a const char *.  That's a good thing.

However, you could naively change that to:

    strcpy((char *)msg, "another string");

and that would compile just fine, but the code would still be a big problem. It 
would require -Wcast-qual to warn you that you're casting away the constness of 
a pointer.

...

For pymemallocator_eq, changing the arguments to const doesn't quiet any 
warnings in this case with this one function.  However, it's good to make them 
const because the arguments are not getting modified.  They're getting passed 
to memcmp(), which properly takes const void *.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39943>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to