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

Definition of the term: free store #5558

Open
FrankHB opened this issue Jul 11, 2022 · 5 comments
Open

Definition of the term: free store #5558

FrankHB opened this issue Jul 11, 2022 · 5 comments

Comments

@FrankHB
Copy link
Contributor

FrankHB commented Jul 11, 2022

A recent change has altered the heading of [class.free]. This still leaves the term "free store" in the index. Unfortunately, there are no other places normativelly define that term (only mentioned as "free store management operators" in [intro.scope]), leading to confusions (e.g. in the comments in this SO answer).

For clarity, either all the occurrence should be removed, or there should be some more concrete normative definition of "free store", with its traditional meaning in computer science, being more consistent with the old uses in Bjarne Stroustrup's publications (than the old wording in [class.free]).

Further, it is still not sufficiently clear what is the "dynamic storage" (in [basic.stc.dynamic.general] et al.). Since we may have translation-time allocations, what does the "dynamic" here precisely mean? Moreover, should be "dynamic storage" and "dynamic storage management" in the index? These questions may deserve another issue, but are likely depending on the treatment on the problem above, so also included here for now.

@jensmaurer
Copy link
Member

jensmaurer commented Jul 11, 2022

If we removed "free store" from the index, would that leave the mention in [intro.scope] as an English-level mention, or should we instead fix [intro.scope] to say "management operators for dynamic memory" and re-point the index entry of "free store" to "dynamic storage duration"?

(Those two are the only mentions of "free store" we have.)

@FrankHB
Copy link
Contributor Author

FrankHB commented Jul 12, 2022

The English-level mention may not work well, as the word "free" is ambiguous in English, and this is exactly the source of some confusions. Pointing "free store" to "dynamic storage duration" is also problematic in this sense.

I'm OK with "free store" once it is well-defined, albeit not the fact that we are lacking of the canonical/authoritative source besides ISO C++. (So searching the Web has little help at current.)

Whether to remove it away or not, we'd still better have the term to denote the region of the storage providing space for the allocation functions by default along with the storage duration. Anyway, the allocated storage are almost mandatory (except for impractical implementations always fail in standard allocation function calls) in C++, so it is virtually a part of the default configuration of the C++ abstract machine. This does deserve some core wording. Fix of [intro.scope] (if any) may better come later.

(BTW, I am personally not satisfied with the approach in ISO C which defers the descriptions of "allocated storage" to library clauses.)

@jensmaurer
Copy link
Member

Ok, so removing mention of the undefined term "free store" from [intro.scope] is what we should do.

Note that we do know what "dynamic storage duration" is; where the memory comes from, is not really the standard's business. (Automatic variables might not be allocated on the stack, either.)

@FrankHB
Copy link
Contributor Author

FrankHB commented Jul 13, 2022

That would be OK to keep it editorial.

The standard does not care about where the source of the memory space is, but it may need to name it. This is not strictly needed in the current standard, but necessary for some finer-grained model, say, operational semantics, or readers would face to meta variables denoting such unnamed things.

Avoiding naming the stack is good, because C++ does not rely on the LIFO nature or the layout of the activation records, so it simplifies the specification and improves portability... until teaching users how "stack unwinding" or "stacktrace" is defined by the standard. (BTW, since the space is invisible, a conforming implementation is allowed to have arbitrary small space for automatic objects and any calls involving them would be fail randomly, i.e. UB. This is ... not that portable. Is this a well-known issue?)

@jwakely
Copy link
Member

jwakely commented Jul 13, 2022

Yes, it's known, but there is no point worrying about hypothetical implementations that have such low resource limits that they are unusable. There are more important things to care about.

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

No branches or pull requests

3 participants