Author petdance
Recipients inada.naoki, petdance, serhiy.storchaka, vstinner
Date 2020-03-27.15:14:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585322082.4.0.956504910176.issue39943@roundup.psfhosted.org>
In-reply-to
Content
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 *.
History
Date User Action Args
2020-03-27 15:14:42petdancesetrecipients: + petdance, vstinner, inada.naoki, serhiy.storchaka
2020-03-27 15:14:42petdancesetmessageid: <1585322082.4.0.956504910176.issue39943@roundup.psfhosted.org>
2020-03-27 15:14:42petdancelinkissue39943 messages
2020-03-27 15:14:42petdancecreate