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

[basic.compound] p3 Improve the definition of the hypothetical array for the arithmetic purpose #5559

Open
xmh0511 opened this issue Jul 11, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jul 11, 2022

[expr.add] p4 defines the concept of pointer arithmetic evaluation

Otherwise, if P points to an array element i of an array object x with n elements...

Which requires we clearly know which element of the array P points to. However, for the pointer arithmetic and comparison purpose, the definition of an object that is not an array element is defined as what [basic.compound] p3 says

an object of type T that is not an array element is considered to belong to an array with one element of type T.

"belong to" is not clear. It is even vague which element of the array is to which a pointer that points to that object would point. Even though the meaning might be inferred from the context. I think the improvement to this definition can be

an object of type T that is not an array element is considered to be the array element 0 of an array with one element of type T.

This can clearly convey that a pointer points to an object of type T that is not an array element can be considered to point to the array element 0 of an array object x with one element of type T for both pointer arithmetic and comparison purpose.

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

1 participant