This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients methane, petdance, serhiy.storchaka, vstinner
Date 2020-03-27.14:08:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585318135.56.0.0205655590706.issue39943@roundup.psfhosted.org>
In-reply-to
Content
> However, it does quiet the -Wcast-qual compiler warning that could be a helpful addition some time in the future.

Aha, that's intesting. It helps me if I can see that your change fix a compiler warning that I can reproduce. If I build Objects/obmalloc.c with -Wcast-qual using GCC 9.2.1 (on Fedora 31), I get:

Objects/obmalloc.c:2455:66: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
 2455 |     fprintf(stderr, "    The %d pad bytes at tail=%p are ", SST, (void *)tail);
      |                                                                  ^


But I get no warning for pymemallocator_eq().


About the (void *) cast, it was added by Zackery Spytz in bpo-36594:

commit 1a2252ed39bc1b71cdaa935d7726d82909af93ab
Author: Zackery Spytz <zspytz@gmail.com>
Date:   Mon May 6 10:56:51 2019 -0600

    bpo-36594: Fix incorrect use of %p in format strings (GH-12769)
    
    In addition, fix some other minor violations of C99.

(...)
-    fprintf(stderr, "    The %d pad bytes at tail=%p are ", SST, tail);
+    fprintf(stderr, "    The %d pad bytes at tail=%p are ", SST, (void *)tail);
(...)

Extract of the issue:

"""
gcc warns with -pedantic:

ptr.c: In function ‘main’:
ptr.c:5:13: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=]
     printf ("%p", &i);
"""

We should check that GCC doesn't emit warning with -pedantic nor -Wcast-qual, and when both flags are combined :-)
History
Date User Action Args
2020-03-27 14:08:55vstinnersetrecipients: + vstinner, methane, serhiy.storchaka, petdance
2020-03-27 14:08:55vstinnersetmessageid: <1585318135.56.0.0205655590706.issue39943@roundup.psfhosted.org>
2020-03-27 14:08:55vstinnerlinkissue39943 messages
2020-03-27 14:08:55vstinnercreate