Skip to content

gh-120593: Fix const qualifier in pyatomic.h - #121055

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:pyatomic_fix_const
Jun 26, 2024
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:pyatomic_fix_const

Conversation

@vstinner

@vstinner vstinner commented Jun 26, 2024 •

Copy link
Copy Markdown
Member
@vstinner

Copy link
Copy Markdown
Member Author

This PR fix the following warnings:

/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h: In function ‘_Py_atomic_load_ptr’:
/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h:300:34: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  300 | { return (void *)__atomic_load_n((void **)obj, __ATOMIC_SEQ_CST); }
      |                                  ^

/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h: In function ‘_Py_atomic_load_ptr_relaxed’:
/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h:359:34: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  359 | { return (void *)__atomic_load_n((const void **)obj, __ATOMIC_RELAXED); }
      |                                  ^

/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h:359:10: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  359 | { return (void *)__atomic_load_n((const void **)obj, __ATOMIC_RELAXED); }
      |          ^
/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h: In function ‘_Py_atomic_load_ptr_acquire’:
/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h:493:34: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  493 | { return (void *)__atomic_load_n((void **)obj, __ATOMIC_ACQUIRE); }
      |                                  ^

/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h: In function ‘_Py_atomic_load_uintptr_acquire’:
/home/vstinner/python/main/Include/cpython/pyatomic_gcc.h:497:37: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
  497 | { return (uintptr_t)__atomic_load_n((uintptr_t *)obj, __ATOMIC_ACQUIRE); }
      |                                     ^

cc1: all warnings being treated as errors
error: command '/usr/bin/gcc' failed with exit code 1
@vstinner

Copy link
Copy Markdown
Member Author

My previous attempt using (const void * const *) cast didn't work well. The correct cast is to (void * const *).

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vstinner
vstinner merged commit 9cd2dcb into python:main Jun 26, 2024
@vstinner
vstinner deleted the pyatomic_fix_const branch June 26, 2024 18:10
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 26, 2024
(cherry picked from commit 9cd2dcb)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app

bedevere-app Bot commented Jun 26, 2024

Copy link
Copy Markdown

GH-121057 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jun 26, 2024
vstinner added a commit that referenced this pull request Jun 26, 2024
)

gh-120593: Fix const qualifier in pyatomic.h (GH-121055)
(cherry picked from commit 9cd2dcb)

Co-authored-by: Victor Stinner <vstinner@python.org>
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants