-
Notifications
You must be signed in to change notification settings - Fork 795
[ub,intro.progress] Added entry for UB due to lack of forward progress #8335
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
base: ub-ifndr
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add to the explicitly called out phrases at the beginning of [ub.general]:
Lines 6 to 9 in f489b81
This Annex documents undefined behavior explicitly called out in the main standard text using the | |
following phrases: the behavior of the program is undefined, has undefined behavior, results in | |
undefined behavior, the behavior is undefined, have undefined behavior, is undefined, result has | |
undefined behavior. Undefined behavior that is implicit is not covered by this annex. Each entry contains |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I get where you are coming from, but I'm not sure it makes sense in this case.
The fact that the UB in [intro.progress] is not called out using one of the phrases listed in [ub.general] is a wording defect which is going to be fixed by CWG2816. So I think we should leave the list of phrases in [ub.general] as-is and instead just apply the proposed resolution in CWG2816, which will change [intro.progress] to explicitly say "the behavior is undefined" instead of "the implementation may assume".
Would that be an acceptable course of action for you?
We just need to make sure that when the wording in [intro.progress] is fixed, the merge conflict between that fix and this PR will be resolved in a way that doesn't accidentally drop the new \ubdef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a little bit weird for [ub.general] to be in contradiction [ub.intro.progress], even if it's temporary. If you do add the phrase to [ub.general] then it can always be removed when CWG2816 eventually gets resolved. This could be recorded under the proposed resolution of CWG2816, so it does not get forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with that approach is that the phrase "the implementation may assume..." does not normally mean "otherwise the behaviour is undefined". The phrase, or variations of it, occur about a dozen times in the Standard, but [intro.progress] is actually the only place where it means "otherwise the behaviour is undefined". In other places, it means things like "we will ignore this case" (e.g., [over.call.func]/2), "we will treat this case as the default" (e.g., [class.access.base]/2), etc.
Since none of the other occurrences of the phrase imply that there is UB, adding the phrase to [ub.general] as you suggest seems outright wrong and I don't think we should do that, not even temporarily.
In other words, yes it seems a little bit weird for [ub.general] to be in contradiction of [ub.intro.progress], but if we add the phrase to [ub.general] as you suggest, then instead it will be in conctradiction with a bunch of other places, and in a way that seems worse (suggesting that there is UB where there is none).
Is there any other resolution that you can live with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any other resolution that you can live with?
I can live with the PR as is, I am not going to die on this hill.
Another option would be to make it clear in [ub.general] that the list of phrases there are not exhaustive.
This Annex documents undefined behavior explicitly called out in the main standard text using
the followingphrases such as:
This Annex documents undefined behavior explicitly called out in the main standard text using, among others, the following phrases:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the list non-exhaustive loses the important property that people can reason about when the text of the Standard means "this is explicit UB" and when it doesn't. Defining a closed set of phrases (and fixing any wording that doesn't use those phrases correctly) is much more useful here in my opinion than defining an open set as you suggest.
We now have a closed set of phrases in [ub.general], and we have one instance of UB that is inconsistent with that in [intro.progress]. So I think the best approach is to fix that one inconsistency by adopting CWG2816 and to move on, not to water down the UB Annex wording or make it more ambiguous (even if temporarily).
So my preference remains to merge this PR as-is, but I am happy for Jens to make the call.
Added
\ubdef{intro.progress.stops}
to [intro.progress]. Added matching entry with code example to [ub]. Note: the wording in [ub] already matches the new wording proposed in CWG2816. When the resolution in CWG2816 is applied to [intro.progress], make sure to not lose the\ubdef
there.