Skip to content

New warnings: warning: unused function 'ensure_shared_on_read' [-Wunused-function] #116029

Description

@Eclips4

Bug report

Bug description:

Popped up during the build (./configure --with-pydebug && make -j):

Objects/dictobject.c:1233:1: warning: unused function 'ensure_shared_on_read' [-Wunused-function]
ensure_shared_on_read(PyDictObject *mp)
^
In file included from Objects/obmalloc.c:16:
In file included from Objects/mimalloc/static.c:23:
Objects/mimalloc/alloc.c:77:5: warning: static function 'mi_debug_fill' is used in an inline function with external linkage [-Wstatic-in-inline]
mi_debug_fill(page, block, MI_DEBUG_UNINIT, mi_page_usable_block_size(page));
^
Objects/mimalloc/alloc.c:30:13: note: 'mi_debug_fill' declared here
static void mi_debug_fill(mi_page_t* page, mi_block_t* block, int c, size_t size) {
...
Objects/dictobject.c:5032:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^                                                    ~~
Objects/dictobject.c:5032:9: note: add parentheses after the '!' to evaluate the comparison first
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^
         (                                                       )
Objects/dictobject.c:5032:9: note: add parentheses around left hand side expression to silence this warning
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^
        (                                                   )
Objects/dictobject.c:5155:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^                                                    ~~
Objects/dictobject.c:5155:9: note: add parentheses after the '!' to evaluate the comparison first
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^
         (                                                       )
Objects/dictobject.c:5155:9: note: add parentheses around left hand side expression to silence this warning
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. changed the title [-]New warning: ` warning: unused function 'ensure_shared_on_read' [-Wunused-function`[/-] [+]New warning: ` warning: unused function 'ensure_shared_on_read' [-Wunused-function]`[/+] on Feb 28, 2024
  2. changed the title [-]New warning: ` warning: unused function 'ensure_shared_on_read' [-Wunused-function]`[/-] [+]New warnings: ` warning: unused function 'ensure_shared_on_read' [-Wunused-function]`[/+] on Feb 28, 2024
  3. colesbury commented on Mar 4, 2024

    @colesbury
    Contributor
  4. sobolevn commented on Mar 4, 2024

    @sobolevn
    Member

    Since this function looks like this:

    static inline void
    ensure_shared_on_read(PyDictObject *mp)
    {
    #ifdef Py_GIL_DISABLED
        if (!_Py_IsOwnedByCurrentThread((PyObject *)mp) && !IS_DICT_SHARED(mp)) {
            // The first time we access a dict from a non-owning thread we mark it
            // as shared. This ensures that a concurrent resize operation will
            // delay freeing the old keys or values using QSBR, which is necessary
            // to safely allow concurrent reads without locking...
            Py_BEGIN_CRITICAL_SECTION(mp);
            if (!IS_DICT_SHARED(mp)) {
                SET_DICT_SHARED(mp);
            }
            Py_END_CRITICAL_SECTION();
        }
    #endif
    }

    I am going to cc @colesbury

  5. sobolevn commented on Mar 4, 2024

    @sobolevn
    Member

    @colesbury it was fast 😆

    I still see this on the latest main:

    Objects/dictobject.c:1242:1: warning: unused function 'ensure_shared_on_read' [-Wunused-function]
    ensure_shared_on_read(PyDictObject *mp)
    ^
    
  6. added 2 commits that reference this issue on Mar 4, 2024
  7. added a commit that references this issue on Mar 25, 2024
  8. added a commit that references this issue on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions