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

Replace "shall not throw" with "does not throw" when it describes library behavior #3229

Merged
merged 1 commit into from Nov 26, 2019

Conversation

Quuxplusone
Copy link
Contributor

In these places we aren't saying "it's UB if it throws"; we're literally specifying the behavior of a library function as "it does not throw, we promise."

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good. The commit comment needs a [lib] in front and should be divorced a little from "throw", because there is also a fix for "shall be a constexpr function" hidden in the changes.

@jensmaurer jensmaurer added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Sep 30, 2019
@jensmaurer
Copy link
Member

Please rebase and fix the conflicts, then force-push.

@jwakely
Copy link
Member

jwakely commented Oct 1, 2019

The existing wording also applies to program-defined specializations of duration and pair. The proposed change makes that less clear IMO.

source/utilities.tex Outdated Show resolved Hide resolved
source/utilities.tex Outdated Show resolved Hide resolved
@Quuxplusone Quuxplusone force-pushed the shall-does branch 2 times, most recently from dd2172f to 8af12ba Compare October 2, 2019 14:55
source/utilities.tex Outdated Show resolved Hide resolved
source/utilities.tex Outdated Show resolved Hide resolved
@jensmaurer jensmaurer added changes requested Changes to the wording or approach have been requested and not yet applied. and removed needs rebase The pull request needs a git rebase to resolve merge conflicts. labels Oct 2, 2019
@jensmaurer
Copy link
Member

@Quuxplusone, there are a few minor changes requested. Please apply them, rebase, and force-push. Thank you.

…ry behavior.

In these places we aren't saying "it's UB if X happens"; we're literally
specifying the behavior of a library function as "X does not happen,
we promise."

Jonathan Wakely points out that there is still room for the user to cause UB
by specializing `pair`, `duration`, `function`, etc. such that their specializations
do X. In that case, the UB happens due to [namespace.std] p2, which requires
that "the [program-defined] specialization meets the standard library requirements
for the original template."
@jensmaurer jensmaurer removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Nov 19, 2019
The defaulted move and copy constructor, respectively, of \tcode{pair} shall
be a constexpr function if and only if all required element-wise
The defaulted move and copy constructor, respectively, of \tcode{pair}
is a constexpr function if and only if all required element-wise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing: s/is a constexpr function/are constexpr functions/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the grammar is: "The X and Y, respectively, is Z if A and B, respectively, satisfies some condition."
I guess you're suggesting: "The X and Y, respectively, are Z if A and B, respectively, satisfy some condition."
Another alternative: "The X or Y, respectively, is Z if A or B, respectively, satisfies some condition."

FWIW, I think this grammar is just too far from proper to have a "right" answer, but my guess was that the singular is more correct — because it's possible for X to be Z independently of Y. Each of X and Y is Z independently of the other.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think this grammar is just too far from proper to have a "right" answer

Amen to that: this sentence is a painfully awkward demonstration of the lengths we'll go to in order to avoid repetition. We should probably simply strike it, since

  • "shall be a constexpr function" doesn't mean what the Library thinks it means,
  • the core language tells us when defaulted constructors are constexpr, there's no need to repeat it here, and
  • [functions.within.classes] says we "do not describe copy/move constructors, assignment operators, or (non-virtual) destructors with the same apparent semantics as those that can be generated by default".

but that may be a bit of a stretch for an editorial change.

Feel free to ignore this comment, accept it, and/or file an LWG issue to strike the paragraph altogether.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awful. But it's pre-existing, so I'm not blocking this pull request on it. If someone wants to take some additional action here, please do! (I think I'll change the "and"s to something else as a short-term "fix".)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, hold on just a minute, this is saying that the defaulted move constructor is constexpr if all copies are valid and the defaulted copy constructor is constexpr if all moves are valid. What the ...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone wants to take some additional action here

Ideally, additional action involving cleansing flame.

@@ -15659,7 +15659,7 @@
reference to an object and a member function pointer. \end{note}

\pnum
\throws Shall not throw exceptions when \tcode{f} is a function pointer
\throws Does not throw exceptions when \tcode{f} is a function pointer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing: the inconsistency between this wording and the wording for the copy constructor is unfortunate. I suggest Does not throw exceptions if \tcode{f} is a function pointer or an instance of a specialization of \tcode{reference_wrapper}.

@zygoloid zygoloid merged commit 1e0b23d into cplusplus:master Nov 26, 2019
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.

None yet

5 participants