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.stc.dynamic.general] Fix definition/explanation of dynamic storage duration #7330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Eisenwave
Copy link
Contributor

@Eisenwave Eisenwave commented Oct 20, 2024

As part of #7261.

This PR fixes numerous issues with [basic.stc.dynamic.general] p1:

  1. "dynamically" is not defined in the standard, and the paragraph does not define it (judging by formatting), so this term is meaningless.

  2. The paragraph specifically states "during program execution", but C++20 allows the user to create dynamic storage duration objects during program translation, i.e. within constant evaluation.

  3. The explanation given here is not exhaustive. Normative wording in [basic.stc.general] p2 already states "The dynamic storage duration is associated with objects created by a new-expression ([expr.new]) or with implicitly created objects ([intro.object]).". Notably, implicitly created objects are not mentioned in [basic.stc.dynamic.general].

It is worth noting that the new definition explicitly gives dynamic storage duration to objects, which is inconsistent with the other definitions. For example, [basic.stc.static] says:

All variables which [...] have static storage duration.

@jensmaurer has stated in #6523 (comment) that we have long-standing problems with the term "variable". At first sight, this may be a blocker for this edit.

However, this editorial issue does not introduce a novel problem because [expr.new] p10 already states:

Objects created by a new-expression have dynamic storage duration ([basic.stc.dynamic]).

In other words, this PR makes no normative changes. It aggregates existing wording from [expr.new] and [basic.stc.general] and replaces old incorrect or incomplete wording.

source/basic.tex Show resolved Hide resolved
source/basic.tex Outdated Show resolved Hide resolved
source/basic.tex Outdated Show resolved Hide resolved
@Eisenwave Eisenwave force-pushed the fix-dynamic-storage-duration branch 2 times, most recently from c25d800 to 78f2a9c Compare October 20, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants