Skip to content

Consider defining "suitably" in each occurrence #7843

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

Open
pmor13 opened this issue Apr 17, 2025 · 4 comments
Open

Consider defining "suitably" in each occurrence #7843

pmor13 opened this issue Apr 17, 2025 · 4 comments

Comments

@pmor13
Copy link

pmor13 commented Apr 17, 2025

The "suitably <something>" almost always confuses me, because what does exactly such "suitably" mean in each occurrence of "suitably"?

Examples:

suitably adjusted
suitably aligned
suitably chosen
suitably instantiated
suitably declared

Different implementors may have different understanding / interpretation of "suitably".

Any comments?

@Eisenwave
Copy link
Contributor

There seems to be a genuine problem here. To pick "suitably aligned" as an example, there exists no definition of "suitably aligned" in [basic.align], just

Attempting to create an object ([intro.object]) in storage that does not meet the alignment requirements of the object's type is undefined behavior.

The reader than has to guess that "suitably aligned storage" is storage that does not violate this rule, which is an unnecessary burden. We ought to be more clear, and we could do that by adding a definition like:

+Storage is suitably aligned for an object
+if it meets the alignment requirements of the object's type.
 Attempting to create an object ([intro.object]) in storage
-that does not meet the alignment requirements of the object's type
+that is not suitably aligned for that object
 is undefined behavior.

I haven't looked at all of the other terms, but I imagine that the fixes are similar, and relatively easy.

@jwakely
Copy link
Member

jwakely commented Apr 25, 2025

If something doesn't meet the relevant requirements and so would cause undefined behaviour, then it's not suitable. Does that really need to be said?

@Eisenwave
Copy link
Contributor

Eisenwave commented Apr 25, 2025

If something doesn't meet the relevant requirements and so would cause undefined behaviour, then it's not suitable. Does that really need to be said?

To be fair, I don't think that a defined term is strictly necessary, but we should at least add an index entry for "suitably aligned storage". Currently, if the reader sees the phrase used, they just have to guess that the relevant rules can be found somewhere towards the end of [basic.align] paragraph 1.

It's not obvious whether "suitably aligned" is a formal term or just some phrase that is based on whether behavior is well-defined according to some paragraph.

@jensmaurer
Copy link
Member

jensmaurer commented Apr 25, 2025

We could also replace "suitably aligned" with "meet the alignment requirements of the object's type" plus a cross-reference, which is more explicit at the point-of-use.

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

4 participants