cplusplus / cplusplus/draft

How many objects or references are associated with a block variable with static storage duration(in multi-thread)?

Open
#5,349 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

void fun(){
  static int value = 0;
}
int main(){
   fun(); // in main thread
  /* fun(); assume in a different thread*/
 /* fun(); assume in a different thread*/
}

we lack the specification for the (block) variable with static storage duration in a similar manner as [class.static.data] p1 did for the static data member. The approach of [class.static.data] p1 is that:

If a static data member is declared thread_­local there is one copy of the member per thread. If a static data member is not declared thread_­local there is one copy of the data member that is shared by all the objects of the class.

The second sentence can imply that we only have one concrete object or reference associated with the static data member regardless of how many threads refers to it.

Don't we need a similar rule for other kinds of variables with static storage duration, non-normative, such as the following:

There is only one object or reference associated with the variable with static storage duration at any time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the example and [class.static.data] p1, then compare its wording with the rules for block variables with static storage duration. Determine whether the draft needs a similar clarification about the number of associated objects or references across threads, and document the resulting standards wording or rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.