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.attr.contract.cond] reference parameters in postconditions #2669

Closed
CaseyCarter opened this issue Feb 15, 2019 · 0 comments
Closed

[dcl.attr.contract.cond] reference parameters in postconditions #2669

CaseyCarter opened this issue Feb 15, 2019 · 0 comments
Assignees

Comments

@CaseyCarter
Copy link
Contributor

[dcl.attr.contract.cond]/7 states:

If a postcondition odr-uses ([basic.def.odr]) a parameter in its predicate and the function body makes direct or indirect modifications of the value of that parameter, the behavior is undefined [ Example: ...

Yet the example in [dcl.attr.contract.syn]/6 includes a function push:

void push(int x, queue & q)
  [[expects: !q.full()]]
  [[ensures: !q.empty()]]
{
  /* ... */
  [[assert: q.is_valid()]];
  /* ... */
}

which seemingly must "directly or indirectly modify the value" of its parameter q to ensure the postcondition !q.empty() holds. If - as suggested to me by @zygoloid - the intent is that the value of a parameter of reference type is simply the glvalue to which the reference is bound, and not the result of lvalue-to-rvalue conversion on that glvalue (which we would normally refer to as "the value of q") then the wording in [dcl.attr.contract.cond]/7 needs clarification.

@jensmaurer jensmaurer changed the title [dcl.attr.contract.cond] [dcl.attr.contract.cond] reference parameters in postconditions Feb 22, 2019
@jensmaurer jensmaurer self-assigned this Mar 10, 2019
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

No branches or pull requests

2 participants