Skip to content

MSVC 5274 warning suppression for _Py_ALIGN_AS should be local #135183

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

Open
encukou opened this issue Jun 5, 2025 · 0 comments
Open

MSVC 5274 warning suppression for _Py_ALIGN_AS should be local #135183

encukou opened this issue Jun 5, 2025 · 0 comments
Assignees
Labels
build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member

encukou commented Jun 5, 2025

Bug report

In #133966 (comment) we added a Python.h-wide suppression for MSVC warning 5274 “Application of _Alignas on a structured type in C”.

I think it should be instead applied locally, after a bit of thought.

AFAICS, 5274 warns that structs compiled with MSVC versions older than 17.9 might end up with a different layout (ABI) than ones compiled with 17.9+. That can cause trouble for extensions.

In PyASCIIObject, _Py_ALIGN_AS is applied to an anonymous struct. I think we can assume that no one is pulling state's type out with something like typeof(my_PyASCIIObject.state) – and if they do, getting an 4B-aligned struct is very unlikely to cause trouble in practice.
But, that is the kind of analysis one should do when a 5274 warning pops up.

Linked PRs

@encukou encukou self-assigned this Jun 5, 2025
@encukou encukou added type-bug An unexpected behavior, bug, or error topic-C-API labels Jun 5, 2025
encukou added a commit to encukou/cpython that referenced this issue Jun 5, 2025
@picnixz picnixz added build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants