gh-105059: Fix MSCV compiler warning on PyObject union by vstinner · Pull Request #107239 · python/cpython · GitHub
Skip to content

gh-105059: Fix MSCV compiler warning on PyObject union - #107239

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:incref_pragram
Jul 25, 2023
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:incref_pragram

Conversation

@vstinner

@vstinner vstinner commented Jul 25, 2023

Copy link
Copy Markdown
Member

Use pragma to ignore the MSCV compiler warning on the PyObject nameless union.

Use pragma to ignore the MSCV compiler warning on the PyObject
nameless union.
@vstinner

Copy link
Copy Markdown
Member Author

@vstinner

Copy link
Copy Markdown
Member Author

I managed to reproduce the issue with this repro.c file:

#include <Python.h>
int main () {
    return 0;
}

I open the "Developer Command Prompt", go Python source code directory, and type cl /c /I Include /I PC /W4 repro.c.

Output on the main branch:

Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32537 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.c
C:\victor\python\main\Include\object.h(178): warning C4201: nonstandard extension used: nameless struct/union
C:\victor\python\main\Include\cpython/unicodeobject.h(199): warning C4100: '_unused_op': unreferenced formal parameter
C:\victor\python\main\Include\cpython/unicodeobject.h(387): warning C4100: '_unused_op': unreferenced formal parameter

=> The warning C4201: nonstandard extension used: nameless struct/union warning is there.

Output with my PR:

Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32537 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.c
C:\victor\python\main\Include\cpython/unicodeobject.h(199): warning C4100: '_unused_op': unreferenced formal parameter
C:\victor\python\main\Include\cpython/unicodeobject.h(387): warning C4100: '_unused_op': unreferenced formal parameter

=> The waning is gone!

@vstinner
vstinner merged commit 1c8fe9b into python:main Jul 25, 2023
@vstinner
vstinner deleted the incref_pragram branch July 25, 2023 14:45
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-107248 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 25, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 25, 2023
…H-107239)

Use pragma to ignore the MSCV compiler warning on the PyObject
nameless union.
(cherry picked from commit 1c8fe9b)

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

Copy link
Copy Markdown

vstinner added a commit that referenced this pull request Jul 25, 2023
) (#107248)

gh-105059: Fix MSCV compiler warning on PyObject union (GH-107239)

Use pragma to ignore the MSCV compiler warning on the PyObject
nameless union.
(cherry picked from commit 1c8fe9b)

Co-authored-by: Victor Stinner <vstinner@python.org>
jtcave pushed a commit to jtcave/cpython that referenced this pull request Jul 27, 2023
…107239)

Use pragma to ignore the MSCV compiler warning on the PyObject
nameless union.
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.

3 participants