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

bpo-31828: make Py_tss_NEEDS_INIT usable in non-static initialisers #4060

Closed
wants to merge 2 commits into from

Conversation

scoder
Copy link
Contributor

@scoder scoder commented Oct 20, 2017

Without the cast, the compound literal is not accepted as a regular RHS value of an assignment.

https://bugs.python.org/issue25658

Without the cast, the compound literal is not accepted as a regular RHS value of an assignment.
@@ -127,7 +127,7 @@ struct _Py_tss_t {
#undef NATIVE_TSS_KEY_T

/* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */
#define Py_tss_NEEDS_INIT {0}
#define Py_tss_NEEDS_INIT ((Py_tss_t) {0})
Copy link
Contributor

@ma8ma ma8ma Oct 20, 2017

Choose a reason for hiding this comment

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

Sadly, the compound literals is not compatible with C++ standard 😣 (it's a C99 feature)
A similar issue of the C-API header was pointed out at related #1362 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, then ... should we just distinguish the C and C++ cases? And maybe even MSVC from the real compilers, as usual?

I mean, this is a public header file. It's fairly annoying if it constrains the applicability of its definitions. I guess I'll have to open a new ticket for this one after all...

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, we've solved an initialization issue of a TSS key by using temporary variables. #1362 (comment)

cpython/Python/pystate.c

Lines 49 to 54 in 731e189

/* A TSS key must be initialized with Py_tss_NEEDS_INIT
in accordance with the specification. */
{
Py_tss_t initial = Py_tss_NEEDS_INIT;
runtime->gilstate.autoTSSkey = initial;
}

@scoder scoder changed the title bpo-25658: make Py_tss_NEEDS_INIT usable in non-static initialisers bpo-31828: make Py_tss_NEEDS_INIT usable in non-static initialisers Oct 20, 2017
@iritkatriel
Copy link
Member

https://bugs.python.org/issue25658 is closed. What is the status of this PR?

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.

None yet

6 participants