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.add] Pointer subtraction when P-Q is out of range of ptrdiff_t is unclear #6268

Closed
vasama opened this issue Jun 6, 2023 · 1 comment · Fixed by #6269
Closed

[expr.add] Pointer subtraction when P-Q is out of range of ptrdiff_t is unclear #6268

vasama opened this issue Jun 6, 2023 · 1 comment · Fixed by #6269

Comments

@vasama
Copy link
Contributor

vasama commented Jun 6, 2023

Otherwise, if P and Q point to, respectively, array elements i and j of the same array object x, the expression P - Q has the value i - j.

When i - j is not in range of ptrdiff_t, this seems to be undefined behaviour due to [expr.pre]. The note on 5.3 should probably be moved here, and a reference to [expr.pre] added.

@jensmaurer
Copy link
Member

Sounds good. Care to submit a pull request?

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