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

[dcl.constexpr]/8.1 should be clearer that declaring a function constexpr can affect its return value if it invokes is_constant_evaluated #3627

Closed
zygoloid opened this issue Jan 13, 2020 · 1 comment · Fixed by #3641
Assignees

Comments

@zygoloid
Copy link
Member

[dcl.constexpr]/8 says:

call to a constexpr function produces the same result as a call to an equivalent non-constexpr function in all respects except that

  • a call to a constexpr function can appear in a constant expression (7.7) and [...]

One non-obvious consequence of this bullet is that because declaring a function constexpr can change whether some expressions are constant expressions, it can change the result of a call to std::is_constant_evaluated within such expressions, which can change the overall value of a call to that function in the context of such a constant expression.

A note to this effect in that bullet would help. ("[Note: This can indirectly cause calls to std::is_constant_evaluated() within an invocation of the function to produce a different value.]")

@zygoloid
Copy link
Member Author

Additional suggestion: talk about a "call to a constexpr function in a given context produces the same result as a call to an equivalent non-constexpr function in the same context in all respects". (The fact that the function is constexpr can affect the context, such as by making it manifestly constant evaluated, and we don't intend to constrain such changes here.)

And in passing change "call to" -> "invocation of".

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 a pull request may close this issue.

2 participants