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

[basic.start.dynamic] says "of a thread", what thread? #1536

Open
burblebee opened this issue Mar 14, 2017 · 3 comments
Open

[basic.start.dynamic] says "of a thread", what thread? #1536

burblebee opened this issue Mar 14, 2017 · 3 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@burblebee
Copy link
Contributor

burblebee commented Mar 14, 2017

The wording added in CWG Motion 10, P0250R3 adds the phrase "whether the dynamic initialization of a non-local non-inline variable with thread storage duration is sequenced before the first statement of the initial function of a thread or is deferred", but "of a thread" isn't clear - what thread?

Comments from Richard:

I actually think this is "of its thread", since we're talking about a specific thread-local variable, whose associated thread is the one we're talking about.

... but the problem is that this requires us to distinguish between the abstract notion of the variable, and the per-thread versions of it, and we don't seem to have good terminology for that distinction. [basic.stc.thread] seems to imply that there is only one "variable" but each thread has its own object or reference, which seems a bit wrong to me but matches the usage here.

In summary, I think this is more "of each thread" than "of any thread" but even that's not quite right. Still, I don't want to get into the subtleties of improving this editorially at this late stage and would rather go ahead with the (less precise than I'd like but probably hard to misinterpret) wording from the paper. Please feel free to open an issue though, and we can look into this post-C++17.

Also added in P0250R3 is wording which says: "the entity for thread t". What entity???
Comments from Richard:

This intends to refer to the thing described in [basic.stc.thread]. But we’re inconsistent in whether we treat a thread_local variable as one entity or multiple.

burblebee referenced this issue Mar 14, 2017
Fixes CWG2046, CWG1784.

[basic.start.dynamic] Swap order of new p2 and old p2 so the description
flows better. Rephrase "avoid deadlocks" note to clarify that it is a
suggestion for implementations and not a consequence of the prior rules.

[basic.start.term] Move last sentence of new p2 into p3 so that it
appears in a more natural place in the description.

[support.start.term] Replace "can" with "may" as this note is discussing
possibility, not permission.
@jensmaurer jensmaurer added this to the C++20 milestone Mar 14, 2017
@burblebee
Copy link
Contributor Author

My 2 cents: I don't think this can be solved editorially. Me thinks there's too many worms in this can.

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Nov 29, 2017
@jensmaurer
Copy link
Member

For local variables, [intro.execution] p1 says:

An instance of each object with automatic storage duration (6.6.4.3) is associated with each entry into its block. Such an object exists and retains its last-stored value during the execution of the block and while the block is suspended (by a call of a function or receipt of a signal).

We're missing a similar paragraph in [intro.multithread], telling us something like

An instance of each object with thread storage duration (xref) is associated with each thread. Such an object exists and retains its last-stored value during the execution of the thread.

If we do this, I think we can get by with fairly light rewording elsewhere and possibly add a cross-reference.

Side note: Talking about "objects" ignores references, but they care for the same rules, I believe.

@jensmaurer jensmaurer added decision-required A decision of the editorial group (or the Project Editor) is required. and removed cwg Issue must be reviewed by CWG. labels Sep 6, 2018
@jensmaurer
Copy link
Member

Editorial meeting: You get a new object each time. "A distinct object with automatic storage duration is associated with a variable with each entry into its block."
Suggest to divorce "variable" from "object". Uncomfortable doing that editorially.

@jensmaurer jensmaurer added cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Nov 6, 2018
@jensmaurer jensmaurer removed this from the C++20 milestone Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

2 participants