Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 26, 2024

@vstinner
Copy link
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
Member Author

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

Copy link
Contributor

@colesbury colesbury left a comment

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
39 checks passed
@vstinner vstinner deleted the pyatomic_fix_const branch June 26, 2024 18:10
@miss-islington-app
Copy link

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 <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 26, 2024

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 bugs and 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 <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants