cplusplus / cplusplus/draft

[basic.stc] Temporary object and its storage duration CWG1634

Open
#4,840 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

[basic.stc.general] p2

Static, thread, and automatic storage durations are associated with objects introduced by declarations ([basic.def]) and implicitly created by the implementation.

The rule explicitly says a temporary object can have a storage duration. However, in the subsequent subclause, the [basic.stc.static], [basic.stc.thread] and [basic.stc.auto] do not state what storage duration the temporary object should have. It only applies to variables.

Since [basic.pre] p6 says

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable's name, if any, denotes the reference or object.

The temporary object is never introduced by a declaration but is created in order to satisfy the requirement of a language construct. Hence, a temporary object is not a variable. This issue is also discussed at https://stackoverflow.com/questions/47945299/what-is-a-temporary-object-with-static-storage-duration

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

Start by reading the cited [basic.stc.general], [basic.stc.static], [basic.stc.thread], [basic.stc.auto], and [basic.pre] paragraphs, then review the linked Stack Overflow discussion. Determine what wording or cross-reference is needed to specify temporary-object storage duration, and consider the issue resolved when the relevant standard text is unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.