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

[expr.prim.req.nested] misuse of term "unevaluated operand" #4830

Open
zygoloid opened this issue Aug 20, 2021 · 1 comment · May be fixed by #4832
Open

[expr.prim.req.nested] misuse of term "unevaluated operand" #4830

zygoloid opened this issue Aug 20, 2021 · 1 comment · May be fixed by #4832
Assignees

Comments

@zygoloid
Copy link
Member

[expr.prim.req.nested]p2: "A local parameter shall only appear as an unevaluated operand (7.2) within the constraint-expression."

This allows requires (T a) { requires sizeof(a) == 4; } but does not allow requires (T a) { requires sizeof(f(a)) == 4; }, because the term "unevaluated operand" only applies to the immediate operand of various contexts. I believe the intent here is "An unqualified-id naming a local parameter shall not be potentially evaluated." or similar.

@zygoloid
Copy link
Member Author

This also seems wrong:

[expr.prim.req.general]p2: "Expressions appearing within a requirement-body are unevaluated operands (7.2)."

Taken literally that would presumably transitively cover all expressions lexically within a requirement-body, allowing requires (int n) { array<int, n>(); }, because n here would be an unevaluated operand.

Even if we interpret this to only apply at the top level and not transitively (which I assume was the intent), this also breaks [expr.prim.req.nested]p2: requires (bool b) { requires b; } is apparently valid, because (the second occurrence of) b here is an unevaluated operand per [expr.prim.req.general]p2 and hence is permitted by [expr.prim.req.nested]p2.

I think we need an explicit list of the places that are treated as unevaluated operands: I think the expression in a simple-requirement or compound-requirement should be, and expressions appearing elsewhere in a requires-expression should receive no special treatment.

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