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.type.cv] P4 doesn't sufficiently define "modify" #1988
Comments
I realized I forgot to clearly state the questions: Is calling a non-const method considered "modifying a const object" for the purposes of that clause, or does it actually have to modify some object of fundamental type? Does the virtualness of the method matter? |
"modifying an object" means applying one of [expr.ass], [expr.post.incr], [expr.pre.incr] to the object or to one of its subobjects. See also [expr.const]p2.17. I'm not seeing an urgent defect, but we could make [expr.ass] p2 clearer by saying "modifies the object referred to by the left operand by replacing the object's value with the value of the right operand". Also, we might consider adding the above list of cross-references when we normatively talk about "modify a const object". |
This definition is obvious, but is it explicitly stated in the standard? |
http://eel.is/c++draft/dcl.type.cv#4:
We are debating whether lines 1 and 2 are valid:
The real world case involves the trivial implementation of an interface with non-const virtual methods. I'd like to declare an instance of that constexpr to ensure it happens before dynamic init, but I couldn't prove if it was valid to cast-away constness on the variable to return a non-const pointer to the interface.
The text was updated successfully, but these errors were encountered: