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
Conversation
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}) | |||
There was a problem hiding this comment.
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
A similar issue of the C-API header was pointed out at related #1362 (comment).
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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)
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; | |
| } |
|
https://bugs.python.org/issue25658 is closed. What is the status of this PR? |
Without the cast, the compound literal is not accepted as a regular RHS value of an assignment.
https://bugs.python.org/issue25658