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.add] Use better example #4778
Conversation
d24eaa9
to
b94b842
Compare
Has the discussion in the linked issue been resolved? @jensmaurer: any thoughts on this? |
I think the main gist here is that using a pointer-to-base when actually pointing to a derived class is fine in most cases, but not in the array indexing case. Changing the example as suggested is losing that point. |
Using a pointer-to-base when actually pointing to an object of derived class type is UB in most (if not all) cases (member access, member function call etc.). Using pointer-to-base which points to the base subobject is fine in all cases (even in the array indexing case). What you can violate with such a pointer, is [expr.add]/4, not [expr.add]/6. |
@jensmaurer I'm not sure what to do here. Should we move this example to p4 and edit the example in p6 like proposed? Or just keep the status quo? |
I like the int / unsigned int example in p6, because it is mildly surprising. I also like to retain the base / derived situation, but maybe it's worthwhile to formulate that in terms of "base class subobject" in p4, as a special case for when the p4.2 precondition isn't satisfied. |
@languagelawyer Could you take another stab at this then? |
b94b842
to
fe81c55
Compare
@jensmaurer not sure what you meant, but I did this. Note, the Note is outside the |
@jensmaurer Could you please take another look here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks reasonable to me.
If you can get @zygoloid to okay these changes, we can apply them right away, otherwise I'd like to have CWG assent.
@languagelawyer could you please have a look? |
fe81c55
to
f33a0e4
Compare
f33a0e4
to
7d96d54
Compare
Related to #3614