-
Notifications
You must be signed in to change notification settings - Fork 751
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
[defns.undefined] Fix the note on undefined behavior in constant evaluation #7206
Conversation
No, that's not the intent. We want that rule "never undefined behavior in constant evaluation" to hold. We do have special rules for the mentioned attributes; see [expr.const] p6.3 and p6.4. |
Currently, the `assmue` and `noreturn` attributes are allowed to bring undefined behavior into constant evaluation. There might be more such standard attributes in the future.
1ae9035
to
8442a84
Compare
The original issue was exactly concerned about these special rules. Is there better way to mention these exceptions in the note? |
Your claim was "Currently, the assmue and noreturn attributes are allowed to bring undefined behavior into constant evaluation." I pointed to the text where that claim is refuted: We continue not to have UB in constant evaluation; we just sometimes make that evaluation not a constant evaluation anymore. In particular, a returning [[noreturn]] function is not UB in constant evaluation; it just keeps going (unless detected). |
So is the intent that when returning from a [[noreturn]] function happens to be allowed in the evaluation of some constant expression, UB is not considered happening? |
That's my understanding: If a [[noreturn]] function returns in constant evaluation, it's either no longer constant evaluation (if your compiler detects that), or it's as-if [[noreturn]] were absent. This is consistent with the idea that attributes can be ignored. |
Oh I see. Then perhaps we should clarify But this isn't what [dcl.attr.assume] and [dcl.attr.noreturn] currently say. Related UB is not excluded from constant evaluation, which seemingly allows constant expression to have arbitrary result when the restrictions are violated. Should there be a CWG issue? |
Closing as the clarification doesn't seem editorial. |
Currently, the
assmue
andnoreturn
attributes are allowed to bring undefined behavior into constant evaluation. There might be more such standard attributes in the future.(Attempted to fix) #7042.