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

P3471R4 Standard library hardening #7703

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

Conversation

Eisenwave
Copy link
Contributor

@Eisenwave
Copy link
Contributor Author

@jwakely I have had some issues when creating this PR:

  • The new note for [string.view.access] looks as if it had a paragraph number, but it's most likely intended to be attached to the hardened precondition paragraph. I have elected to ignore the paragraph number.

  • The paper deletes "Two kinds of implementations are defined" in [intro.compliance] but the library has the same sort of wording in [compliance] (library intro). How to proceed? Delete redundant wording? Mirror changes?

  • [structure.specifications] in the paper explains "Hardened preconditions" simply with two bullets that begin with "When". This is not how we usually do things. My suggestion would be something like "If the implementation is hardened ([intro.compliance]), ..." for the first bullet, and "Otherwise, ..." for the second bullet.

  • [basic.contract.eval] is a dead reference at this point. It should be resolved after merging with contracts.

  • It was very annoying that the paper doesn't have a wording diff that follows the structure of the standard linearly. For example, the paper first has the wording diff for 23.7.3.6.3 [mdspan.mdspan.members], and then the diff for 27.7.3.6.2 [mdspan.mdspan.cons]. The only thing this accomplishes is to bully the editor, and I'm the editor, and I feel bullied!

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Feb 26, 2025

  • The new note for [string.view.access] looks as if it had a paragraph number, but it's most likely intended to be attached to the hardened precondition paragraph. I have elected to ignore the paragraph number.

The old note was semantically connected to the preconditions paragraph but placed in a bad (IMO) place. I guess the intent wasn't attaching the note to the paragraph, but such attaching seems to be an editorial improvement to me.

  • The paper deletes "Two kinds of implementations are defined" in [intro.compliance] but the library has the same sort of wording in [compliance] (library intro). How to proceed? Delete redundant wording? Mirror changes?

I think it's safest to mirror changes.

Copy link
Contributor

@burblebee burblebee left a comment

Choose a reason for hiding this comment

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

The paper was applied correctly except for 2 missing edits, but there were other issues - see comments.

Comment on lines 828 to 829
A freestanding
implementation is one in which execution may take place without the benefit of
Copy link
Contributor

Choose a reason for hiding this comment

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

Not your doing (from existing text), but wanted to point out that this is where the \defnadj for "freestanding implementation" should be (not above) since this is the definition. Same for "hosted implementation" in the sentence below.

Copy link
Member

Choose a reason for hiding this comment

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

I think we want the defnadj to be on the first occurrence of the term.

It is
\impldef{whether the implementation is a hardened implementation}
whether the implementation is a
\defnadj{hardened}{implementation}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also not your doing (from paper), but this doesn't define what a "hardened implementation" is - what is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not uncommon that we use definition italics for things that aren't really explained, but simply the first occurrence of that term. I wouldn't be opposed to some semi-normative wording that attempts to define it, but that seems outside the scope of this PR, even considering fixups.

Copy link
Member

Choose a reason for hiding this comment

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

The way it was stated in R2 was "A hardened implementation is one in which violating a hardened precondition is a contract violation." That is a bit more like an actual definition, but I don't think it's a problem the way R4 is phrased. We specify the properties of a hardened implementation, and say it's implementation-defined whether the implementation is one. That's sufficient IMHO. An impl has to say if it is or isn't one, and if it is, we say how that affects behaviour.

Comment on lines 371 to +378
\item
\expects
the conditions
that the function assumes to hold whenever it is called;
conditions that the function assumes to hold whenever it is called;
violation of any preconditions results in undefined behavior.

\item
\hardexpects
conditions that the function assumes to hold whenever it is called.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a problem with existing source, but also the new source since it's following the existing convention:

  • \clauses should always be preceded with a \pnum, not an \item, and
  • Sentences following each \clause should start with capital letter.

prior to any other observable side effects of the function,
one or more contract assertions
whose predicates are as described in the hardened precondition
are evaluated with a checking semantic\iref{basic.contract.eval}.
Copy link
Contributor

Choose a reason for hiding this comment

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

[basic.contract.eval] doesn't exist; is it being added by one of the other motions?

Copy link
Contributor

Choose a reason for hiding this comment

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

#7695 is adding that section.

@@ -9372,7 +9372,7 @@

\begin{itemdescr}
\pnum
\expects
\hardexpects
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing 2 of these edits around line 9418 for [expected.void.obs]/p7 and line 9435 for expected.void.obs/p9.

@@ -837,6 +856,11 @@
Freestanding implementations should only define a macro from \libheader{version}
if the implementation provides the corresponding facility in its entirety.

\pnum
\recommended
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have 2 \recommendeds following each other like this, verses having a bulleted list under a single \recommended?

Copy link
Contributor Author

@Eisenwave Eisenwave Mar 5, 2025

Choose a reason for hiding this comment

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

I think it would be stylistically better if there was a single paragraph, and I don't even think that bullets are required.

However, it's not really wrong, and CWG signed off on it knowing that there are two recommendations in a row, so I'm not sure if that's a fixup candidate.

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.

[2025-02 LWG Motion 15] P3471R4 Standard Library Hardening P3471 R3 Standard Library Hardening
4 participants